Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank You Norman - I Appreciate Your Help!!!!
"Norman Jones" wrote: Hi MWS, Try handling the password directly: '============= Private Sub Worksheet_Activate() Dim res As Variant res = Application.InputBox _ (Prompt:="Enter password", Type:=3) On Error GoTo XIT: ActiveSheet.Unprotect password:=res On Error GoTo 0 Rows("2:5000").Select Selection.EntireRow.Hidden = False Range("A1:L5004").Select Selection.Sort Key1:=Range("A2"), _ Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, _ Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Rows("2:2").Select ActiveWindow.FreezePanes = True Range("A1").Select Exit Sub XIT: MsgBox "Your password was not recognised""" End Sub '<<============= -- --- Regards, Norman "MWS" wrote in message ... Norman, Thank You, this addresses the inputting of an incorrect password. A point I failed to mention and perhaps you can help with is, if the user chooses "cancel" instead of inputting a password at the prompt an error message is displayed. Can this too be avoided with code and if so, what would it be? Thanks Again - I Appreciate Your Help "Norman Jones" wrote: Hi MWS, Try: '============= Private Sub Worksheet_Activate() On Error GoTo XIT: ActiveSheet.Unprotect On Error GoTo 0 Rows("2:5000").Select Selection.EntireRow.Hidden = False Range("A1:L5004").Select Selection.Sort Key1:=Range("A2"), _ Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, _ Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Rows("2:2").Select ActiveWindow.FreezePanes = True Range("A1").Select Exit Sub XIT: MsgBox "Your password was not recognised""" End Sub '<<============= --- Regards, Norman "MWS" wrote in message ... Hello, My goal is to have code to, upon activating a sheet, to unprotect the sheet if the user imputs the correct password and then complete some other tasks (the "other" portion I have figured out. The code is as follows: Private Sub Worksheet_Activate() If ActiveSheet.Protect = False Then ActiveSheet.Unprotect Rows("2:5000").Select Selection.EntireRow.Hidden = False Range("A1:L5004").Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Rows("2:2").Select ActiveWindow.FreezePanes = True Range("A1").Select End If The issue is, if the user does not value the correct password, they receive an error. My question is: What is the code to be added so if the user inputs the correct password the code continues and if the incorrect password is valued the execution aborts and the error meesage is not presented (I realize the user just needs to click "end" when then error is received, but I'd like to have a cleaner process). Any and All Help Is Appreciated - Thank You |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code Execution Message | Excel Discussion (Misc queries) | |||
How to ged rid of the "Execution Error 9" message at the file opening? | Excel Discussion (Misc queries) | |||
message without stopping execution? | Excel Programming | |||
Code Execution has been interrupted message | Excel Programming | |||
Message Box Execution | Excel Programming |