Temporarily Disable auto protect code

EBoudreau

Board Regular
Joined
Aug 21, 2015
Messages
153
Is there a way I can temporarily disable automatic protecting in the following code?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


    Dim rng As Range
    
    Application.EnableEvents = False
    ActiveSheet.Unprotect Password:="WellingtonFrac"
    
    Set rng = Intersect(Target, Range("E8:CZ31, E48:CZ59"))
    If Not rng Is Nothing Then Call Capitalise(rng)
        
    Set rng = Intersect(Target, Range("D55:D1585"))
    If Not rng Is Nothing Then Call ConvertToTime(rng)
    
    ActiveSheet.Protect Password:="WellingtonFrac"
    Application.EnableEvents = True


End Sub

What it's doing is...
I Unprotect the sheet, make an edit in a cell or a range of cells, then page goes back to being protected. Then i have unprotect the sheet again, make an edit, then it pops right back to protected. I'm looking for a way to temporarily disable that password protection without deleting the lines of code because I will end up wanting to reenable that code to protect again when i'm done making edits.

Any ideas?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
for instance if you said in a1 you placed an x and at the top of the code you had it check a1 and if it returns x then exit sub
 
Upvote 0
example only

Code:
IF sheets("yoursheetname"),range("A1") = "x" then Exit Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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