AllowEditRanges 集合

         
Protection
AllowEditRanges
AllowEditRange

所有 AllowEditRanges 对象的集合,这些对象代表受保护的工作表中可编辑的单元格区域。

AllowEditRanges 集合用法

使用 Protection 对象的 AllowEditRanges 属性可返回一个 AllowEditRanges 集合。

返回一个 AllowEditRanges 集合后,可用 Add 方法在受保护的工作表中添加一个可编辑的区域。

本示例中,Microsoft Excel 允许用户在活动工作表中编辑区域 A1:A4,并将指定区域的标题和地址通知用户。

Sub UseAllowEditRanges()

    Dim wksOne As Worksheet

    Set wksOne = Application.ActiveSheet

    ' Unprotect worksheet.
    wksOne.Unprotect

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

    ' 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