Share via


Protection.AllowEditRanges Property

Excel Developer Reference

Returns an AllowEditRanges object.

Syntax

expression.AllowEditRanges

expression   A variable that represents a Protection object.

Example

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.

Visual Basic for Applications
  Sub UseAllowEditRanges()
Dim wksOne As Worksheet
Dim strPwd1 As String

Set wksOne = Application.ActiveSheet

strPwd1 = InputBox("Enter Password")

' Unprotect worksheet.
wksOne.Unprotect

' Establish a range that can allow edits
' on the protected worksheet.
wksOne.Protection.<strong>AllowEditRanges</strong>.Add _
    Title:="Classified", _
    Range:=Range("A1:A4"), _
    Password:=strPwd1

' Notify the user
' the title and address of the range.
With wksOne.Protection.<strong>AllowEditRanges</strong>.Item(1)
    MsgBox "Title of range: " &amp; .Title
    MsgBox "Address of range: " &amp; .Range.Address
End With

End Sub

See Also