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.

Macro

publicado

Hola buenas soy nuevo en esto de Excel pero me gustaría que me ayudaran a crear una macro.quiero crear una macro para borrar contenido de celdas cuando llegue a una fecha específica; gracias

Featured Replies

  • 3 weeks later...
publicado

Jelow,

Adjunto archivo de ejemplo y dejo código abajo:

Sub borrarDatosAnteriores()

    Dim fecha As Date
    Dim rangoTabla, i As Variant
    
    fecha = ActiveSheet.Range("$B$3").Value
    
    i = 2
    
    Do While i <= ActiveSheet.ListObjects("Table22").Range.Rows.Count
        
        ActiveSheet.ListObjects("Table22").Range(i, 4).Select
        
        With Selection.Cells(1)
        
            Set rangoTabla = Intersect(.EntireRow, ActiveCell.ListObject.DataBodyRange)
            
            If rangoTabla(1, 4) < fecha Then
                
                rangoTabla.Delete xlShiftUp
                
                GoTo NextIteration
            End If
        End With
        
        i = i + 1
        
NextIteration:
    Loop
End Sub

A tener en cuenta:

1.- Aconsejable hacer esto siempre con formatos tabla, porque es más fácil acceder a los datos y no tocar otros rangos.

2.- En este caso (desde mi desconocimiento) igual el código es un poco burdo y se puede hacer algo más optimizado.

3.- Una vez hecho, la opción Cntrl + Z no devolverá las celdas eliminadas, así que ojo con eso...

 

Cualquier aclaración sobre el código, quedo al tanto ?

 

Nada más, espero haberte ayudado. 

Book1.xlsm

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

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.