![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Ireland
Posts: 133
|
Is it possible to write a macro that will hide all sheets except one? If so, how do I go about it?
Thanx!! |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Hi,
Say you wanted all sheets hidden except Sheet1 you can use this:- Sub HideAllSheetsBarOne() Dim sht As Object For Each sht In Sheets If sht.Name <> "Sheet1" Then sht.Visible = xlSheetHidden End If Next sht End Sub If you want the sheets hidden so they can't be unhidden using Format, Sheet, Unhide change the xlSheetHidden bit it xlSheetVeryHidden. That way the sheets in question can only be unhidden using VBA. HTH, Dan |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi,
Please try this, and you will need to modify the sheet name.
|
|
|
|
|
|
#4 | |
|
Board Regular
Join Date: Mar 2002
Location: Hellas
Posts: 553
|
Quote:
_________________ Best Regards, Andreas using Excel 2000 - Windows 2000 prof. [ This Message was edited by: sen_edp on 2002-05-14 01:36 ] |
|
|
|
|
|
|
#5 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
|
||
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Mar 2002
Location: Hellas
Posts: 553
|
Hello Ivan,
Sorry I was not clear , i mean if you use in the hide macro the xlveryhidden command, what you put in the unhide macro ?
__________________
Best Regards Andreas
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Location: Ireland
Posts: 133
|
Thank you both very much, they work a treat. One final question (at least I hope it's the final question!). How can I tell it to unhide all of the sheets except one? It's the same one each time, namely 2003.
Thanks again, you've really been a great help |
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Mar 2002
Location: Hellas
Posts: 553
|
Thanks Ivan
__________________
Best Regards Andreas
|
|
|
|
|
|
#9 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
work even if xlveryhidden is set. The const xlSheetveryhidden only hides it from the Window > Unhide view. |
|
|
|
|
|
|
#10 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Sub test1() Dim sh As Worksheet For Each sh In Worksheets If sh.Name <> "2003" Then sh.Visible = xlSheetVisible Next End Sub |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|