Consulting

Results 1 to 5 of 5

Thread: Solved: Dynamic List of Worksheet Names based on criteria

  1. #1

    Solved: Dynamic List of Worksheet Names based on criteria

    I've been searching the forum for a while now and can't seem to find what I'm looking for. Is it possible to make a dynamic list of worksheet names of all worksheets that have "TPL" in cell K2? I'd also like the list to automatically update whenever a new sheet is added that matches the cell criteria.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Are you adding a sheet that contains TPL, or writing TPL into an existing sheet?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    One sheet is used as a template that has TPL in the cell. Then it's copied as a new sheet

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Put the following in ThisWorkbook module
    [VBA]
    Private Sub Workbook_Open()
    Listing
    End Sub

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Listing
    End Sub

    Sub Listing()
    Dim sht As Worksheet
    For Each sht In Sheets
    If sht.Range("K2") = "TPL" Then
    i = i + 1
    Sheets("Sheet1").Cells(i, 1) = sht.Name '<--Change to suit
    End If
    Next
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    That's what I needed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •