Hide unhide sheets

R

Reijer

Hello Excellers,

With a value in cel B23 on every sheet i want to hide or unhide the sheets.
Standard they are hidden when i start. Who can help me with a procedure for
this pls?

Greetings,

Reijer.
 
M

Martin Fishlock

Reijer:

You can hide/unhide sheets with the following VBA command

activesheet.visible=true/false.

So to go thru all the worksheets in a workbook and check depending on if
there is a value in B23:

Option Explicit

Sub CheckAllWorksheets()

Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
If ws.Range("B23").Value <> "" Then
ws.Visible = xlSheetVisible
Else
ws.Visible = xlSheetHidden
End If
Next ws

End Sub
 
Top