Runtime error when closing the sheetHi all,

P

praveen_khm

Hi all,
This is a simple macro to hide the sheets if macro is disabled. But I
get an error when I close the worksheet. Can anyone please help me with
this. Other than that, everything seems fine. The problem is only when
closing the worksheet if get an error as " run-time error '1004':
Method ;visible' of object' _worksheet' failed". The code is given
below.


Public bIsClosing As Boolean
Dim wsSheet As Worksheet

Sub HideAll()

Application.ScreenUpdating = False
For Each wsSheet In ThisWorkbook.Worksheets
If wsSheet.CodeName = "TABLE" Then
wsSheet.Visible = xlSheetVisible
Else
wsSheet.Visible = xlSheetVeryHidden
End If
Next wsSheet
Application.ScreenUpdating = True

End Sub

Sub ShowAll()
bIsClosing = False

For Each wsSheet In ThisWorkbook.Worksheets
If wsSheet.CodeName <> "TABLE" Then
wsSheet.Visible = xlSheetVisible
End If
Next wsSheet
End Sub


Please help.....
 

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

Top