Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
publicado

Hola amigos de Ayuda Excel.

Buenos dias, tengo una tabla y deseo proteger la hoja, He investigado pero las tabla no funcionan en hojas protegidas, sin embargo, he encontrado varios articulos que las tablas pueden funcionar con hojas protegidas a través de macros. Incluso conseguí un código pero particularmente no me funciona. 

Me podrán ayudar a ver por qué no funciona

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Row = 1 Then Exit Sub
If Target.Column > 8 Then Exit Sub
On Error Resume Next
With ActiveSheet
ActiveSheet.Unprotect Password:="123"
.ListObjects("Tabla11").Resize Target.CurrentRegion
ActiveSheet.Protect ("123")
End With
On Error GoTo 0

End Sub

prueba TABLA PROTEGIDA.xlsm

Editado el por Leonardo Briceño
falto información en titulo

Solucionado por JSDJSD

Ir a la solución

Featured Replies

publicado

Prueba y comentaimage.thumb.gif.96e84fb4e2ddd013bac18243b00d9656.gif

Private Sub Worksheet_Change(ByVal Target As Range)
    ' Salir si se seleccionan varias celdas a la vez
    If Target.Count > 1 Then Exit Sub

    ' Salir si el cambio está en la fila 1
    If Target.Row = 1 Then Exit Sub

    ' Salir si el cambio está en una columna mayor a la columna 8
    If Target.Column > 8 Then Exit Sub

    ' Intentar redimensionar la tabla dentro de la protección de hoja
    On Error GoTo ErrorHandler
    Me.Unprotect Password:="123"

    ' Redimensiona la tabla a la región actual del Target
    Me.ListObjects("Tabla1").Resize Target.CurrentRegion

    ' Proteger de nuevo con configuraciones específicas para permitir edición en la tabla
    Me.Protect Password:="123", _
               AllowSorting:=True, _
               AllowFiltering:=True, _
               AllowUsingPivotTables:=True, _
               AllowInsertingRows:=True, _
               AllowDeletingRows:=True

    ' Restaurar control de errores
    On Error GoTo 0
    Exit Sub

ErrorHandler:
    MsgBox "Ocurrió un error al redimensionar la tabla. Verifica el nombre de la tabla y que los rangos estén correctos.", vbExclamation
End Sub

 

publicado
  • Autor

Super @JSDJSD funciona a la perfección!!!!!

Muchas gracias.  Con esta opción de tablas que había leído antes pero nunca había puesto en práctica es muy eficiente. 

Mi archivo original tiene 10.000 filas con formula y son 15 hojas. El archivo se pone pesado y lento. Con esta opción sera mas rapido y menos pesado el archivo.

Nuevamente gracias.😃

publicado
  • Autor

Disculpa    @JSDJSD , si ya tengo el evento  Private Sub Worksheet_Change(ByVal Target As Range) activo con otra macro, como agrego la solución que me diste?

Intente con la instrucción Else pero no logro hacerlo con éxito.

Gracias

                  

publicado
  • Autor

Gracias, Te comento:

Con hoja desprotegida tabla funciona bien. Protegida no funciona.

Macro Original de la hoja no ejecuta instrucciones

Crear una cuenta o conéctate para comentar

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.