LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 103
Default macro to hide sheets

On Mon, 10 Aug 2009 07:46:34 -0500, Dave Peterson
wrote:

Sometimes, If/then statements can get unruly with lots of criteria.


Agreed; I considered ptting a Select Case in my own response but
decided to keep it to as close to the original code as possible.
Select Case is still preferred though.

Private Sub CommandButton2_Click()
dim i as long
For i = 1 To Worksheets.Count
select case lcase(worksheets(i).codename)
case is = "sheet1","sheet5","sheet9" 'all lower case!
'do nothing
case else
sheets(i).visible = xlsheethidden
end select
next i
Sheet1.Select
End Sub

EricBB wrote:

why the below is not working? pls. help...

Private Sub CommandButton2_Click()
For i = 1 To Worksheets.Count
If Not (Worksheets(i).CodeName = "Sheet1" Or "Sheet5" Or "Sheet9") Then
Sheets(i).Visible = False
Next
Sheet1.Select
End Sub


 
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
Hide Sheets KrispyData Excel Discussion (Misc queries) 2 March 25th 09 06:42 PM
Can you hide Sheets? Abdul Excel Discussion (Misc queries) 10 November 30th 08 07:09 PM
Macro-Hide & Unhide Sheets with condition [email protected] Excel Discussion (Misc queries) 8 August 22nd 07 02:04 AM
If I have my sheets protected will that prevent me running a macro to hide certain sells? Marc Excel Worksheet Functions 0 May 17th 06 11:36 PM
macro to hide sheets ditchy Excel Discussion (Misc queries) 8 May 2nd 05 02:21 AM


All times are GMT +1. The time now is 06:12 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"