ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Password Oddity (https://www.excelbanter.com/excel-programming/363437-password-oddity.html)

SamuelT[_20_]

Password Oddity
 

Hi all,

So I've got some code (helped by some of you forumeers) tha
unprotects, filters, then reprotects the sheet. This has worked fine
but now when I go to manually unprotect a sheet, Excel tells me this i
the wrong password. I checked and rechecked the code and the password i
definitely right. I've pasted it below - and ideas what's going on?

Sub SL()
Sheets("Programme (2 Week)").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=9, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True, Password:="donotouch"
Sheets("Programme (High Level)").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=9, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True, Password:="donotouch"
Sheets("Capacity").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=5, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True, Password:="donotouch"
Sheets("Components").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=3, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True, Password:="donotouch"
Sheets("Billing").Select
ActiveSheet.Unprotect Password:="donottouch"
ActiveWindow.ScrollColumn = 1
Selection.AutoFilter Field:=3, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True, Password:="donotouch"
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Extra Fees Calculator").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=3, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True, Password:="donotouch"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Programme (2 Week)").Select
End Su

--
Samuel
-----------------------------------------------------------------------
SamuelT's Profile: http://www.excelforum.com/member.php...fo&userid=2750
View this thread: http://www.excelforum.com/showthread.php?threadid=54901


DS

Password Oddity
 
Hi Samuel,

Not sure if this is what's causing it, but it's worth a shot - you've got
some different passwords in there, varying from unprotect to protect.

unprotecting, you're using "donottouch"
protecting, you're using "donotouch"

This would also mean that once run, and the sheets are reprotected under
"donotouch", running again where it tries to unprotect with "donottouch" will
fail, as will manual unprotect attempts using "donottouch"!

Don't you just hate typos!!

HTH
DS

"SamuelT" wrote:


Hi all,

So I've got some code (helped by some of you forumeers) that
unprotects, filters, then reprotects the sheet. This has worked fine,
but now when I go to manually unprotect a sheet, Excel tells me this is
the wrong password. I checked and rechecked the code and the password is
definitely right. I've pasted it below - and ideas what's going on?

Sub SL()
Sheets("Programme (2 Week)").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=9, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="donotouch"
Sheets("Programme (High Level)").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=9, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="donotouch"
Sheets("Capacity").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=5, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="donotouch"
Sheets("Components").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=3, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="donotouch"
Sheets("Billing").Select
ActiveSheet.Unprotect Password:="donottouch"
ActiveWindow.ScrollColumn = 1
Selection.AutoFilter Field:=3, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="donotouch"
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Extra Fees Calculator").Select
ActiveSheet.Unprotect Password:="donottouch"
Selection.AutoFilter Field:=3, Criteria1:="Steve Lomax"
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="donotouch"
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Programme (2 Week)").Select
End Sub


--
SamuelT
------------------------------------------------------------------------
SamuelT's Profile: http://www.excelforum.com/member.php...o&userid=27501
View this thread: http://www.excelforum.com/showthread...hreadid=549017




All times are GMT +1. The time now is 02:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com