Dazzybeeguy
Board Regular
- Joined
- Jan 6, 2022
- Messages
- 118
- Office Version
- 365
- 2010
- Platform
- Windows
Hi
I have been protecting the worksheet without using a Password but now I want to add on but the Macros wont run with current code, I have added an example below. Is there a quick easy way to Change The ActiveSheet.Unprotect by adding the password i.e. 123 so just a line like ActiveSheet.Unprotect Password"123" and same but for Protect at the end, Thanks
Sub Clear1_9()
'
' Clear1_9 Macro
ActiveSheet.Unprotect
Range("C9:BH9").Select
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
End Sub
I have been protecting the worksheet without using a Password but now I want to add on but the Macros wont run with current code, I have added an example below. Is there a quick easy way to Change The ActiveSheet.Unprotect by adding the password i.e. 123 so just a line like ActiveSheet.Unprotect Password"123" and same but for Protect at the end, Thanks
Sub Clear1_9()
'
' Clear1_9 Macro
ActiveSheet.Unprotect
Range("C9:BH9").Select
Selection.ClearContents
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
End Sub