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.

Problema con EntireRow.Delete

publicado

Estoy corriendo una macro que en el Rango A1:A15 deberia contar las celdas con "Roles de tripulacion", poner en la siguiente celda vacia del rango "x Roles de tripulacion" y borrar todas las filas del rango que contengan "Roles de tripulacion". La cuestion es que cuando intento con el ejemplo, me borra solamente dos de las cuatro filas que tengo con ese valor. 

Adjunto el archivo para mejor ilustracion.

Sub test()
If Application.WorksheetFunction.CountIf(Sheets(1).Range("A1:A15"), "Roles de tripulacion") > 0 Then
Sheets(1).Range(Range("A1").End(xlDown).Offset(1).Address).Value = Application.WorksheetFunction.CountIf(Sheets(1).Range("A1:A15"), "Roles de tripulacion") & " Roles de Tripulacion"
For y = 1 To 15
With Sheets(1)
               If Range("A" & y) = "Roles de tripulacion" Then
               Rows(y).EntireRow.Delete
                           End If
       End With
   Next y
   
   End If
End Sub
 

Sample.xlsm

Featured Replies

publicado

Solamente tienes que invertir el ciclo

Sub test()
If Application.WorksheetFunction.CountIf(Sheets(1).Range("A1:A15"), "Roles de tripulacion") > 0 Then
Sheets(1).Range(Range("A1").End(xlDown).Offset(1).Address).Value = Application.WorksheetFunction.CountIf(Sheets(1).Range("A1:A15"), "Roles de tripulacion") & " Roles de Tripulacion"
    For y = 15 To 1 Step -1
        With Sheets(1)
            If Range("A" & y) = "Roles de tripulacion" Then
                Rows(y).EntireRow.Delete
            End If
        End With
    Next y
End If
End Sub

 

publicado
  • Autor
1 hour ago, JSDJSD said:

Solamente tienes que invertir el ciclo

Sub test()
If Application.WorksheetFunction.CountIf(Sheets(1).Range("A1:A15"), "Roles de tripulacion") > 0 Then
Sheets(1).Range(Range("A1").End(xlDown).Offset(1).Address).Value = Application.WorksheetFunction.CountIf(Sheets(1).Range("A1:A15"), "Roles de tripulacion") & " Roles de Tripulacion"
    For y = 15 To 1 Step -1
        With Sheets(1)
            If Range("A" & y) = "Roles de tripulacion" Then
                Rows(y).EntireRow.Delete
            End If
        End With
    Next y
End If
End Sub

 

Muchas gracias!

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.