Worksheet excluded doesn't exclude
Dave,
You should not be using a For Next loop for this. By doing so, you are
testing against every sheet in the workbook, not just the changed sheet.
Get rid of the For Next and it works for me.
It was also confusing to me that you changed the default "ByVal Sh as
Object" to "ws" and then used the ws in your loop. This does not seem like
good practice to me.
hth,
Doug
"davegb" wrote in message
ups.com...
This is part of some code I wrote to limit acess to some spreadsheets.
It's supposed to ignore the sheet "(Code Key)". But it still asks for a
password.
Private Sub Workbook_SheetChange(ByVal ws As Object, ByVal Target As
Range)
Dim sShName As String
For Each ws In ActiveWorkbook.Worksheets
If Right(ws.Name, 7) < "Monthly" Then 'ignore these sheeets
Select Case ws.Name
Case "(Code Key)" 'Excluded sheets
Exit Sub
Case Else 'if password hasn't been entered yet, then ask
for password
If bPwrdEntrd = False Then
Call PasswordEntry
End If
End Select
End If
Next
End Sub
I tried using CodeName instead of sheet name, but that didn't work
either. Does anyone see what is wrong?
Thanks again.
|