Protection![]() ![]() ![]() |
Uma coleção de todos os objetos AllowEditRanges que representa as células que podem ser editadas em uma planilha protegida.
Usar a coleção AllowEditRanges
Use a propriedade AllowEditRanges do objeto Protection para retornar uma coleção AllowEditRanges.
Depois que a coleção AllowEditRanges foi retornada, você pode usar o método Add para adicionar um intervalo que pode ser editado em uma planilha protegida.
Neste exemplo, o Microsoft Excel permite a edição do intervalo "A1:A4" na planilha ativa e notifica o usuário sobre o título e endereço do intervalo especificado.
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