a way to conditionally hide tabs in a range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I’m not sure if this is possible but I’m searching for a solution using a
control(selection of a cell) or button to take a range of worksheets, to
first unhide all work sheets, then check a condition in one cell on each of
the worksheets if the condition is positive then hide that sheet.
 
Try something like the following:

Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
If WS.Range("A1").Value = "Show" Then
WS.Visible = xlSheetVisible
Else
WS.Visible = xlSheetHidden
End If
Next WS


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Great Thanks for your help!

Chip Pearson said:
Try something like the following:

Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
If WS.Range("A1").Value = "Show" Then
WS.Visible = xlSheetVisible
Else
WS.Visible = xlSheetHidden
End If
Next WS


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
The code assumes that there will always be at least one sheet
that will be made visible. A workbook cannot have 0 visible
worksheets.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top