Here is more of the code. I will attach the file if necessary. I believe that other workbooks are using this error handler because maybe it's not specific enough, such as on error code: xxxx goto errhandler??
Whenever I open up a new workbook, I get a debugging prompt. It's because I'm trying to protect a specific worksheet name, and when I'm opening a new workbook, that sheet name does not exist.
I'd like to get more detailed in the error handler and if I cannot get past this situation, then I cannot get even more detailed in my error handler. (I have about 28 sheets, and I need to do things with these as well.)
Here is the code:
Private Sub Worksheet_Activate()
Run "AddMenus"
Dim r As Range, cell As Range
On Error GoTo ErrHandler
Set r = Me.Range("J13,J15:J18,J20:J21,J24,J26,J28:J30,J32,J43:J50,J53:J59,J70:J72,J74:J75,J81:J84,J86,J92:J99,J101:J107,V115:V150")
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each cell In r
If cell.Value = 0 Then
Sheets("Balancing Sheet").Unprotect Password:="1234"
cell.EntireRow.Hidden = True
Else
Sheets("Balancing Sheet").Unprotect Password:="1234"
cell.EntireRow.Hidden = False
End If
Next
ErrHandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Sheets("Balancing Sheet").Protect Password:="1234"
Sheets("Balancing Sheet").Protect Password:="1234"
End Sub
Private Sub Worksheet_Deactivate()
Run "DeleteMenu"
End Sub
Private Sub Worksheet_Calculate()
Dim r As Range, cell As Range
On Error GoTo ErrHandler
Set r = Me.Range("V35,J61:J62")
Application.ScreenUpdating = False
Application.EnableEvents = False
For Each cell In r
If cell.Value = 0 Then
Sheets("Balancing Sheet").Unprotect Password:="1234"
cell.EntireRow.Hidden = True
Else
Sheets("Balancing Sheet").Unprotect Password:="1234"
cell.EntireRow.Hidden = False
End If
Next
ErrHandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Sheets("Balancing Sheet").Protect Password:="1234"
Sheets("Balancing Sheet").Protect Password:="1234"
End Sub
Bookmarks