+ Reply to Thread
Results 1 to 3 of 3

Loop thru sheets with particular name format

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-16-2011
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    405

    Question Loop thru sheets with particular name format

    Hi all,

    I need a way to be able to loop between sheets that names are in the following format: ##-##-####
    where # represents any number.
    The sheet names are dates and my workbook contains other worksheets i want to exclude from this loop

    any help would be appreciated!

    cheers

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Loop thru sheets with particular name format

    Maybe try this (untested):

    For s = 1 to Sheets.Count
        If Sheets(s).name like "*" & "-" & "*" & "-" & "*" Then Msgbox Sheets(s).name
    Next
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Loop thru sheets with particular name format

    This slightly different approach will test if almost any date format has been used and properly identify them all, even if they differ:

    12-12-2012
    1-1-11
    May 2012

    Sub NameTest()
    Dim ws As Worksheet
    
    For Each ws In Worksheets
        If IsDate(CStr(ws.Name)) Then MsgBox ws.Name
    Next ws
    
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1