Hi Guys
I've been struggling to solve this problem for a few hours now. I have an overall password ("XYZ") protecting the overall sheet, and then a 2nd password for Range("rngB_O") - password "ABC". I need this code to not only unlock the column ( Selection.Locked = False), but to allow users to format cells in a cell in this range.
The code: Selection.EnableSelection = False (to prevent format cells) & Selection.EnableSelection = True (to enable format cells) is not working for me.
Any thoughts please?
'**************************************************************************
' Macros to unhide or hide columns for Management Company
'**************************************************************************
Sub pwdManCoy()
Application.ScreenUpdating = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Sheet1.Unprotect Password:="XYZ"
Dim passMan As String
passMan = InputBox("Bitte geben Sie Ihr Passwort")
If passMan <> "ABC" Then
MsgBox "Bitte starten Sie das korrekte Passwort für Verwaltungsgesellschaft", vbOKOnly, "Falsches Passwortfür für die Verwaltungsgesellschaft"
' Protecting columns if password entered in WRONG!!!
Sheet1.Range("rngB_O").Select
Selection.Locked = True
Selection.FormulaHidden = True
Else
' Unprotecting columns if password entered is correct
Sheet1.Range("rngB_O").Select
Selection.Locked = False
Selection.FormulaHidden = False
End If
Sheet1.Protect Password:="Leipzig"
Application.ScreenUpdating = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
End Sub
I've been struggling to solve this problem for a few hours now. I have an overall password ("XYZ") protecting the overall sheet, and then a 2nd password for Range("rngB_O") - password "ABC". I need this code to not only unlock the column ( Selection.Locked = False), but to allow users to format cells in a cell in this range.
The code: Selection.EnableSelection = False (to prevent format cells) & Selection.EnableSelection = True (to enable format cells) is not working for me.
Any thoughts please?
'**************************************************************************
' Macros to unhide or hide columns for Management Company
'**************************************************************************
Sub pwdManCoy()
Application.ScreenUpdating = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
Sheet1.Unprotect Password:="XYZ"
Dim passMan As String
passMan = InputBox("Bitte geben Sie Ihr Passwort")
If passMan <> "ABC" Then
MsgBox "Bitte starten Sie das korrekte Passwort für Verwaltungsgesellschaft", vbOKOnly, "Falsches Passwortfür für die Verwaltungsgesellschaft"
' Protecting columns if password entered in WRONG!!!
Sheet1.Range("rngB_O").Select
Selection.Locked = True
Selection.FormulaHidden = True
Else
' Unprotecting columns if password entered is correct

Sheet1.Range("rngB_O").Select
Selection.Locked = False
Selection.FormulaHidden = False
End If
Sheet1.Protect Password:="Leipzig"
Application.ScreenUpdating = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
End Sub