AllowEditRange object (Excel)
Represents the cells that can be edited on a protected worksheet.
Remarks
Use the Add method or the Item property of the AllowEditRanges collection to return an AllowEditRange object.
After an AllowEditRange object has been returned, you can use the ChangePassword method to change the password to access a range that can be edited on a protected worksheet.
Example
In this example, Microsoft Excel allows edits to range "A1:A4" on the active worksheet, notifies the user, and then changes the password for this specified range and notifies the user of this change.
Sub UseChangePassword()
Dim wksOne As Worksheet
Dim wksPassword As String
Set wksOne = Application.ActiveSheet
wksPassword = InputBox ("Enter password for the worksheet")
' Establish a range that can allow edits
' on the protected worksheet.
wksOne.Protection.AllowEditRanges.Add _
Title:="Classified", _
Range:=Range("A1:A4"), _
Password:=wksPassword
MsgBox "Cells A1 to A4 can be edited on the protected worksheet."
' Change the password.
wksPassword = InputBox ("Enter the new password for the worksheet")
wksOne.Protection.AllowEditRanges(1).ChangePassword _
Password:=wksPassword
MsgBox "The password for these cells has been changed."
End Sub
Methods
Properties
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.