AllowEditRanges Object
Collapse the table of content
Expand the table of content

AllowEditRanges Object (Excel)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

A collection of all the AllowEditRange objects that represent the cells that can be edited on a protected worksheet.

Use the AllowEditRanges property of the Protection object to return an AllowEditRanges collection.

Once an AllowEditRanges collection has been returned, you can use the Add method to add a range that can be edited on a protected worksheet.

In this example, Microsoft Excel allows edits to range "A1:A4" on the active worksheet and notifies the user of the title and address of the specified range.

Sub UseAllowEditRanges() 
 Dim wksOne As Worksheet 
 Dim wksPassword As String 
 Set wksOne = Application.ActiveSheet 
 ' Unprotect worksheet. 
 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"), _ 
 ' Notify the user 
 ' the title and address of the range. 
 With wksOne.Protection.AllowEditRanges.Item(1) 
 MsgBox "Title of range: " & .Title 
 MsgBox "Address of range: " & .Range.Address 
 End With 
End Sub
© 2016 Microsoft