Delete AllowEditeRanges by VBA

Solved/Closed
issa - Apr 17, 2011 at 10:57 AM
 Issa - Apr 26, 2011 at 07:20 AM
Dear All,

Can some-body help me to correct the following code:

Private Sub CommandButton1_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

This Code I do it to remove all AllowEditeRanges in every sheet, but unfortunately it works only in the sheet that the command button exists and NOT for every sheet.

So can anyone help me and thanks in advance.

1 response

You have told it only to look at the ActiveSheet.

For Each aer In ActiveSheet.Protection.AllowEditRanges
0
Dear RayH,

First of al thanks to your reply, it didn't worked because I need it to work in EVERY worksheet in the workbook, not only in the active sheet, so I need it to work in every sheet.

Thank you in advance for your kind assistant.
Issa
0
It solved.Thanks a lot.
0