Estoy ejecutando esta macro, y continuamente me muestra 'Error definido por la aplicación o el objeto':
Sub ProtegerHoja()
Dim fila As Long
fila = Sheets("Hoja1").Range("A1048576").End(xlUp).Row
Dim contraseña As String
contraseña = "abcd"
With ActiveSheet
.Protection.AllowEditRanges.Add Title:="Rango1", _
Range:=Range("A3:H" & fila), _
Password:=contraseña
.Protect Password:=contraseña, _
DrawingObjects:=True, _
Contents:=True
.EnableSelection = xlNoRestrictions
End With
End Sub
No sé dónde puede estar el error... Por más que lo reviso, no logro encontrarlo.
De todos modos, he consultado la documentación que disponemos de Microsoft VBA en Internet, y en el código que dan como ejemplo también me muestra el mismo error.
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.AllowEditRanges.Add _
Title:="Classified", _
Range:=Range("A1:A4"), _
Password:=strPwd1
' 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
Os agradezco enormemente cualquier tipo de ayuda u orientación...
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
Hola amigos del foro,
Estoy ejecutando esta macro, y continuamente me muestra 'Error definido por la aplicación o el objeto':
Sub ProtegerHoja() Dim fila As Long fila = Sheets("Hoja1").Range("A1048576").End(xlUp).Row Dim contraseña As String contraseña = "abcd" With ActiveSheet .Protection.AllowEditRanges.Add Title:="Rango1", _ Range:=Range("A3:H" & fila), _ Password:=contraseña .Protect Password:=contraseña, _ DrawingObjects:=True, _ Contents:=True .EnableSelection = xlNoRestrictions End With End Sub
No sé dónde puede estar el error... Por más que lo reviso, no logro encontrarlo.
De todos modos, he consultado la documentación que disponemos de Microsoft VBA en Internet, y en el código que dan como ejemplo también me muestra el mismo error.
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.AllowEditRanges.Add _ Title:="Classified", _ Range:=Range("A1:A4"), _ Password:=strPwd1 ' 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
Os agradezco enormemente cualquier tipo de ayuda u orientación...