Delete ALL AllowEditRanges in command Button [Solved/Closed]

Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Dear Sir,

I have the following VBA code:

Private Sub CommandButton2_Click()
Dim WS As Worksheet
Dim aer As AllowEditRange

For Each WS In Worksheets
For Each aer In ActiveSheet.Protection.AllowEditRanges
aer.Delete

Next aer
Next WS

End Sub

I need to modify this VBA in order to work for all worksheets, it works now only for the sheet that have the command button but the other sheets still having the AllowEditRange.

Therefore, some one if know what to add to this VBA or to change it in order when I click one command button to remove / delete all AllowEditRanges in all worksheets.

Thank you in advance

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
760
Change this line

ActiveSheet.Protection.AllowEditRanges

to

WS .Protection.AllowEditRanges
1
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2942 users have said thank you to us this month