Saltar al contenido

Borrar toda la fila si no encontró el valor en el VLOOKUP

publicado

Qué tal, estoy teniendo problemas intentando eliminar la fila completa si no encuentra el valor en el vlookup, intenté filtrando y eliminando después del vlookup, en la condición del vlookup intenté la función .entireRow.Delete y aunque no me marca error, nunca termina de ejecutar la macro completa.

¿ Cómo puedo eliminar la fila completa del valor que no encuentre en el VLOOKUP ?

'VLOOKUP
   Dim Celda As Range, z As Long
    Application.ScreenUpdating = False
    Range("L:L").Clear
    For z = 2 To Range("B" & Rows.Count).End(xlUp).Row
        Set Celda = Sheets("Copia").Range("A:A").Find(Range("B" & z), , , xlWhole)
        If Not Celda Is Nothing Then
            Range("L" & z) = Celda.Offset(0, 6)
        Else
            Range("L" & z) = ""
            'Range("L" & z).Interior.Color = vbGreen
        End If
    Next
    
    'Filter and delete
    Dim RowToTest2 As Long

    For RowToTest2 = Cells(Rows.Count, 12).End(xlUp).Row To 3 Step -1

    With Cells(RowToTest2, 12)
    If .Value <> "Mexico Co CARS" _
    And .Value <> "Mexico Otras" _
    And .Value <> "Mexico P&S" _
    And .Value <> "Mexico S&M" _
    Then _
    Rows(RowToTest2).EntireRow.Delete
    End With

    Next RowToTest2

 

Featured Replies

publicado

Sin ver el archivo y sin explicar que quieres hacer va a ser imposible.

publicado
Sub EliminarFilas()
Application.ScreenUpdating = False
For x = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
   If Range("L" & x) = "" Then Rows(x).Delete
Next
End Sub

 

Archivado

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