Delete ALL AllowEditRanges in command Button [Solved/Closed]

- - Latest reply: rizvisa1
Posts
4475
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
- Jul 3, 2011 at 08:24 AM
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
See more 

1 reply

Best answer
Posts
4475
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
January 6, 2016
753
1
Thank you
Change this line

ActiveSheet.Protection.AllowEditRanges

to

WS .Protection.AllowEditRanges

Say "Thank you" 1

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

CCM 6109 users have said thank you to us this month