Help with macro code

  • Thread starter Thread starter Db1712
  • Start date Start date
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
 
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
 
Hey...Thanks just needed to change a couple of lines and it worked. Yo
are a life save
 

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

Similar Threads


Back
Top