Uh oh...Runtime error 1004!!!!

Z

zenahs

Thanks to all of you that have helped me get my Excel workbook to wher
it is today. I now have a problem though...I think that two macros ar
conflicting. I currently have a button in use to run a macro that lock
and protects various cells in various worksheets throughout my workboo
(this is used to prevent end-users from editing or deleting my data o
these worksheets while, at the same time, leaving some cells open fo
their updating). The other macro that I am running is a "BeforeClose
macro that hides all worksheets upon closing (this is used to ensur
that end-users "enable" macros upon opening the workbook. If the
don't enable...they can't see the worksheets.)

Here is the error that I'm getting:
Runtime '1004'
Method 'Visible' of '_Worksheet' failed.

Is there a way to fix this? Is there a different way to accomplish th
same thing?

For reference purposes, here's the beforeclose macro I'm using:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("T2020").Select

x = MsgBox("Have you updated the T2020?", vbYesNo, "T2020 Reminder")

If x = vbNo Then
Cancel = True
End
End If
Dim WS As Worksheet

Sheets("PERMISSION").Visible = xlSheetVisible

For Each WS In ThisWorkbook.Worksheets
If Not WS.Name = "PERMISSION" Then
WS.Visible = xlSheetVeryHidden
End If
Next WS

End Sub

Thanks for your 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