Help with macro code

D

Db1712

I have a simple command button macro to hide a work sheet page. Is ther
a way to keep the sheet from being hidden if there is a value in boxe
e.g “g13,o13,g24,o24” then open a msgbox “sheet in use”. Thanks fo
any help with this

Private Sub CommandButton5_Click()

Application.ScreenUpdating = False
Sheets("Sun Misc Log").Visible = False
Application.ScreenUpdating = True
End Su
 
N

Norman Jones

Hi DB1712,

Try:

Private Sub CommandButton1_Click()
Dim rng As Range
Dim blHide As Boolean

With Me
Set rng = Union(.Range("G13"), .Range("O13"), _
.Range("G24"), .Range("O24"))
End With

blHide = Application.CountA(rng) = 0

Application.ScreenUpdating = False
If blHide Then
Sheets("Sun Misc Log").Visible = xlHidden
Else
MsgBox "Sheet in use"
End If
Application.ScreenUpdating = True
End Sub
 
D

Db1712

Hey...Thanks just needed to change a couple of lines and it worked. Yo
are a life save
 
Top