multiple password protected pages with same password and using macros

WindowGuy

New Member
Joined
Sep 12, 2023
Messages
18
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
I have been trying lots of things i found on youtube but either it wont unlock or relock....

This is in workbook. I have tried more then one page(,"Installs","Crystal") but it errors out.
VBA Code:
Private Sub Workbook_Open()

Call AllowMacroWhenProtected

End Sub


Sub AllowMacroWhenProtected()

Sheets("Master Quote DO NOT TOUCH").Protect Password:="7712", _
    UserInterfaceOnly:=True

End Sub

i have also placed the following in the pages. but if leaves it unlocked after clicking macro button. It also will not run macro if i lock it at end of each sub.


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
ThisWorkbook.Worksheets("Install Quote").Unprotect ("7712")
With Application
   
Num = .Match(Range("AW14").Value, Split("one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen,twenty", ","), 0)
End With

Rows("27:287").Hidden = False
If IsNumeric(Num) Then Rows(Num * 13 + 14 & ":287").Hidden = True



End Sub


Sub NewDropDownDefault()
ThisWorkbook.Worksheets("Install Quote").Unprotect ("7712")
Range("N8").ClearContents
   Dim Rng As Range
   Application.ScreenUpdating = False
   On Error Resume Next
   Set Rng = ActiveSheet.UsedRange.SpecialCells(xlCellTypeAllValidation)
   Rng.Value = "'- Choose Option -"
   On Error GoTo 0
ThisWorkbook.Worksheets("Install Quote").Protect ("7712")

End Sub
Private Sub Workbook_Open()

Call AllowMacroWhenProtected

End Sub


Sub AllowMacroWhenProtected()

Sheets("Install Quote").Protect Password:="7712", _
    UserInterfaceOnly:=True

End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top