View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Sandy Sandy is offline
external usenet poster
 
Posts: 270
Default Run code conditional on sheet visibility

Hi Mike

Works perfectly!

Thank You

"Mike" wrote in message
...
Dim ws As Worksheet
Dim wsCount As Long
wsCount = 0
For Each ws In Worksheets

If ws.Visible = xlSheetVisible Then
wsCount = wsCount + 1
End If
Next

If wsCount = 1 Then
If Worksheets("Sheet2").Visible = True Then
MsgBox "One sheet visible and the were looking for"
Else
MsgBox "One sheet visible but not the were looking for"
End If
Else
MsgBox "More then one sheet visable"
End If

"Sandy" wrote:

Hi
I have a situation whereby if sheet "LogGraph3" is the only sheet visible
then I do not require the Workbook_BeforeClose to run, how do I
incorporate
that into the following.

******Sub Starts******
Sub Workbook_BeforeClose(Cancel As Boolean)

If Sheets("LogGraph3") 'is the only visible sheet' Then
GoTo EarlyEnd

Else
Do closing code
End If

EarlyEnd:
Some Code

End Sub
******Sub Ends*******

Thanks
Sandy