wilg
08-07-2010, 07:33 AM
Hi. I have some protect worksheet codes that if I have another workbook open will protect the sheets on that workbook as well as the one this code lies within. Is there something I should do differnt to ensure the code I write only runs in the workbook I have the code? This happens with other code I use as well?
Sub ProtectAll()
Application.ScreenUpdating = False
Dim Sh As Worksheet
Dim myPassword As String
myPassword = password
For Each Sh In activeWorkbook.Worksheets
Sh.Protect Password:=myPassword
Next Sh
Sheets("sheets 1").Visible = False
Application.ScreenUpdating = True
End Sub
Sub ProtectAll()
Application.ScreenUpdating = False
Dim Sh As Worksheet
Dim myPassword As String
myPassword = password
For Each Sh In activeWorkbook.Worksheets
Sh.Protect Password:=myPassword
Next Sh
Sheets("sheets 1").Visible = False
Application.ScreenUpdating = True
End Sub