Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Hide/Show some worksheets

Is there a way to use VB code to hide/show a group of worksheets at once,
possibly using a wildcard? I have a worksheet that contains many sheets that
need to be Veryhidden or Visible easily without having to go
thru the Format/Sheet/Hide menu. Each worksheet is named for a week of the
year. (i.e. "(Wk 1) 12-1-2008", "(Wk 2) 12-8-2008", "(Wk 3) 12-15-2008"
etc). The
current week named "Current Status" will always be visible. Idealy if a
wildcard for any worksheet containing "Wk" could be used would work great.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hide/Show some worksheets

Option Explicit
Sub testme()
Dim sh As Object

'make sure that there's always one sheet visible first
Worksheets("Current status").Visible = xlSheetVisible

For Each sh In ActiveWorkbook.Sheets
If LCase(sh.Name) = LCase("current status") Then
'skip it
Else
If LCase(sh.Name) Like LCase("wk*") Then
sh.Visible = xlSheetHidden
End If
End If
Next sh
End Sub



Tony S. wrote:

Is there a way to use VB code to hide/show a group of worksheets at once,
possibly using a wildcard? I have a worksheet that contains many sheets that
need to be Veryhidden or Visible easily without having to go
thru the Format/Sheet/Hide menu. Each worksheet is named for a week of the
year. (i.e. "(Wk 1) 12-1-2008", "(Wk 2) 12-8-2008", "(Wk 3) 12-15-2008"
etc). The
current week named "Current Status" will always be visible. Idealy if a
wildcard for any worksheet containing "Wk" could be used would work great.
Thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Hide/Show some worksheets

Dave, as usual, you're a genius. Your code does exactly what I wanted.
Thank you sir.

"Dave Peterson" wrote:

Option Explicit
Sub testme()
Dim sh As Object

'make sure that there's always one sheet visible first
Worksheets("Current status").Visible = xlSheetVisible

For Each sh In ActiveWorkbook.Sheets
If LCase(sh.Name) = LCase("current status") Then
'skip it
Else
If LCase(sh.Name) Like LCase("wk*") Then
sh.Visible = xlSheetHidden
End If
End If
Next sh
End Sub



Tony S. wrote:

Is there a way to use VB code to hide/show a group of worksheets at once,
possibly using a wildcard? I have a worksheet that contains many sheets that
need to be Veryhidden or Visible easily without having to go
thru the Format/Sheet/Hide menu. Each worksheet is named for a week of the
year. (i.e. "(Wk 1) 12-1-2008", "(Wk 2) 12-8-2008", "(Wk 3) 12-15-2008"
etc). The
current week named "Current Status" will always be visible. Idealy if a
wildcard for any worksheet containing "Wk" could be used would work great.
Thanks!


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Show/Hide Inez Excel Discussion (Misc queries) 1 July 8th 09 03:29 PM
show hide row if Wanna Learn Excel Discussion (Misc queries) 2 May 15th 09 06:08 PM
Hide/Show some worksheets Tony S.[_2_] Excel Discussion (Misc queries) 8 January 18th 09 07:28 PM
Hide and show a group of worksheets dreamkeeper Excel Programming 3 March 28th 06 09:02 PM
Hide and show Cl Excel Programming 1 January 3rd 04 03:45 PM


All times are GMT +1. The time now is 05:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"