Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Macro to hide sheets based upon cell value

I need help with 3 macros for hiding sheets:

1) I would like to hide several sheets based upon the value of a cell i.e.
A1 within the sheet to possibly be hidden.

2) I need a macro to unhide all hidden sheets. Some sheets are not hidden.

3) I need to hide certain sheets using the name of the sheet.

Thanks in advance for your help!
Joe M.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to hide sheets based upon cell value

#1.

Dim wks as worksheet
for each wks in activesheet.worksheets
if lcase(wks.range("a1").value) = lcase("hideme") then
wks.visible = xlsheethidden
end if
next wks

#2

Dim wks as worksheet
for each wks in activesheet.worksheets
'don't bother to see if it's visible or not
wks.visible = xlsheetvisible
next wks

#3.

Dim wks as worksheet
for each wks in activesheet.worksheets
if lcase(wks.name) like lcase("*somecommonstring*") then
wks.visible = xlsheethidden
end if
next wks

Remember that with #1 and #3, at least one sheet has to be visible.

Joe M. wrote:

I need help with 3 macros for hiding sheets:

1) I would like to hide several sheets based upon the value of a cell i.e.
A1 within the sheet to possibly be hidden.

2) I need a macro to unhide all hidden sheets. Some sheets are not hidden.

3) I need to hide certain sheets using the name of the sheet.

Thanks in advance for your help!
Joe M.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 97
Default Macro to hide sheets based upon cell value

Dave,

I created a macro with only the code you showed for #1. I got this error:
Object doesn't support this property or method (Error 438)
What did I do wrong?

Thanks,
Joe M.

"Dave Peterson" wrote:

#1.

Dim wks as worksheet
for each wks in activesheet.worksheets
if lcase(wks.range("a1").value) = lcase("hideme") then
wks.visible = xlsheethidden
end if
next wks

#2

Dim wks as worksheet
for each wks in activesheet.worksheets
'don't bother to see if it's visible or not
wks.visible = xlsheetvisible
next wks

#3.

Dim wks as worksheet
for each wks in activesheet.worksheets
if lcase(wks.name) like lcase("*somecommonstring*") then
wks.visible = xlsheethidden
end if
next wks

Remember that with #1 and #3, at least one sheet has to be visible.

Joe M. wrote:

I need help with 3 macros for hiding sheets:

1) I would like to hide several sheets based upon the value of a cell i.e.
A1 within the sheet to possibly be hidden.

2) I need a macro to unhide all hidden sheets. Some sheets are not hidden.

3) I need to hide certain sheets using the name of the sheet.

Thanks in advance for your help!
Joe M.


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro to hide sheets based upon cell value

It was a typo (times 3).

Use:
For Each wks In ActiveWorkbook.Worksheets
not
For Each wks In ActiveSheet.Worksheets


Joe M. wrote:

Dave,

I created a macro with only the code you showed for #1. I got this error:
Object doesn't support this property or method (Error 438)
What did I do wrong?

Thanks,
Joe M.

"Dave Peterson" wrote:

#1.

Dim wks as worksheet
for each wks in activesheet.worksheets
if lcase(wks.range("a1").value) = lcase("hideme") then
wks.visible = xlsheethidden
end if
next wks

#2

Dim wks as worksheet
for each wks in activesheet.worksheets
'don't bother to see if it's visible or not
wks.visible = xlsheetvisible
next wks

#3.

Dim wks as worksheet
for each wks in activesheet.worksheets
if lcase(wks.name) like lcase("*somecommonstring*") then
wks.visible = xlsheethidden
end if
next wks

Remember that with #1 and #3, at least one sheet has to be visible.

Joe M. wrote:

I need help with 3 macros for hiding sheets:

1) I would like to hide several sheets based upon the value of a cell i.e.
A1 within the sheet to possibly be hidden.

2) I need a macro to unhide all hidden sheets. Some sheets are not hidden.

3) I need to hide certain sheets using the name of the sheet.

Thanks in advance for your help!
Joe M.


--

Dave Peterson
.


--

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
macro to hide sheets EricBB Excel Discussion (Misc queries) 5 August 10th 09 07:49 PM
Writing a macro to hide columns based on cell value JAbels001 Excel Discussion (Misc queries) 2 April 16th 09 05:02 PM
Hide or unhide sheets based on cell billinr Excel Discussion (Misc queries) 2 July 13th 07 07:42 PM
Hide sheets based on Cell value Mike Milmoe Excel Discussion (Misc queries) 4 January 16th 07 05:57 AM
Formula or Macro to hide a row based on a cell value JP Excel Discussion (Misc queries) 0 February 3rd 06 06:10 PM


All times are GMT +1. The time now is 01:35 AM.

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

About Us

"It's about Microsoft Excel"