Delete ALL AllowEditRanges in command Button [Solved/Closed]

Issa - Apr 14, 2011 at 12:49 PM - Latest reply: rizvisa1 4481 Posts Thursday January 28, 2010Registration dateContributorStatus January 6, 2016 Last seen
- 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
rizvisa1 4481 Posts Thursday January 28, 2010Registration dateContributorStatus January 6, 2016 Last seen - Jul 3, 2011 at 08:24 AM
1
Thank you
Change this line

ActiveSheet.Protection.AllowEditRanges

to

WS .Protection.AllowEditRanges

Thank you, rizvisa1 1

Something to say? Add comment

CCM has helped 1706 users this month