Consulting

Results 1 to 3 of 3

Thread: Solved: wildcard use with xlSheetVeryHidden ?

  1. #1
    VBAX Contributor
    Joined
    Jul 2009
    Posts
    157
    Location

    Solved: wildcard use with xlSheetVeryHidden ?

    All - I have a series of worksheets that begin with the same 7 characters of "Budget-" followed by their month and year making up the worksheet name.

    I would like to use xlSheetVeryHidden for them but do not want to have to call each one out specifically each time a new one is added.

    I want to convert the code below to one that will hide any worksheet beginning with "Budget-". This is similar to a wildcard being used in the sheet name.
    [VBA]
    Worksheets("Budget-Jan2010").Visible = xlSheetVeryHidden
    [/VBA]

    I played around with adding in some fashion the code below to the xlSheetVeryHidden command but could not get it to work.
    [VBA]
    Left$(wk.Name, 7) <> "Budget-"
    [/VBA]

    Any ideas how to accomplish this ? Can a wildcard be used in this command or would the Left$ function be needed ?

    thanks !

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    One idea

    [vba]
    For Each sh In Activeworkbook.Worksheets

    If sh.Name Like "Budget-*" Then

    sh.Visible = xlSheetVeryHidden
    End If
    Next sh
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Jul 2009
    Posts
    157
    Location
    Yep, that does it....thanks XLD !

Posting Permissions

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