+ Reply to Thread
Results 1 to 6 of 6

Selecting worksheets in a workbook based on criteria

  1. #1
    Registered User
    Join Date
    02-19-2004
    Posts
    57

    Selecting worksheets in a workbook based on criteria

    hi,

    how can i select worksheets in a workbook based on a certain criteria.

    For example, I have worksheets that start with "18" together with other worksheets.
    1811, 1812, 1813....1899, Data, PivotTable, etc....

    how can I select only the worksheets starting with "18" using a macro?

    these worksheets are generated by showing all pages using a pivottable. hence the using the Sheets(Array(x,y,z...)).Select will not work.
    as its difficult to determine the exact no. of sheets starting with "18" everytime the macro is run.

    any help is greatly appreciated!

    josnah

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why do you need to Select the sheets, it is usually unnecessary in VBA?

    This code will select all sheets starting with 18

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    or maybe

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    02-19-2004
    Posts
    57
    thanks both for your help...

    i'll need to select the sheets first and then run another macro to format the sheets...
    i may not be technically correct by doing this.
    i'm not sure if i can not select the sheets first but run the other macro on sheets beginning with "18"
    Any help is greatly appreciated

    Josnah

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    You can loop through the sheets something like this.

    Puts the Sheet name in Range A1 and makes it bold

    Please Login or Register  to view this content.
    VBA Noob

  6. #6
    Registered User
    Join Date
    02-19-2004
    Posts
    57
    thanks alot VBA Noob!

    That works just great now and yes faster too...

+ 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