Codigo para buscar "Order was shipped from the Coppell distribution center" en la columna A y despues borrar hasta el blank

Estoy buscando un codigo que busque esta oracion "Order was shipped from the Coppell distribution center" en la columna A y despues de encontrarla que borre todo hacia arriba hasta llegar a un espacio en blanco.

1 respuesta

Respuesta
1

H o l a:

Si quieres solamente borrar los datos de la columna A, utiliza la siguiente macro

Sub BuscarBorrar()
'Por.Dante Amor
    Set b = ActiveSheet.Columns("A").Find("Order was shipped from the Coppell distribution center")
    If Not b Is Nothing Then
        If Cells(b.Row - 1, "A") = "" Then
            Range("A" & b.Row).ClearContents
        Else
            Range("A" & b.Row & ":A" & Range("A" & b.Row).End(xlUp).Row).ClearContents
        End If
    End If
End Sub

Si quieres borrar el contenido de todas las filas:

Sub BuscarBorrar2()
'Por.Dante Amor
Set b = ActiveSheet.Columns("A").Find("Order was shipped from the Coppell distribution center")
If Not b Is Nothing Then
If Cells(b.Row - 1, "A") = "" Then
Range("A" & b.Row).EntireRow.ClearContents
Else
Range("A" & b.Row & ":A" & Range("A" & b.Row).End(xlUp).Row).EntireRow.ClearContents
End If
End If
End Sub

Si quieres eliminar las filas:

Sub BuscarBorrar3()
'Por.Dante Amor
    Set b = ActiveSheet.Columns("A").Find("Order was shipped from the Coppell distribution center")
    If Not b Is Nothing Then
        If Cells(b.Row - 1, "A") = "" Then
            Range("A" & b.Row).Delete
        Else
            Range("A" & b.Row & ":A" & Range("A" & b.Row).End(xlUp).Row).Delete
        End If
    End If
End Sub

¡Gracias!

El ultimo código era el que necesitaba solo que me acabo de dar cuenta que en las celdas de la B a la H también tengo información que tengo que eliminar.

La macro sería así:

Sub BuscarBorrar3()
'Por.Dante Amor
    Set b = ActiveSheet.Columns("A").Find("Order was shipped from the Coppell distribution center")
    If Not b Is Nothing Then
        If Cells(b.Row - 1, "A") = "" Then
            Range("A" & b.Row).EntireRow.Delete
        Else
            Range("A" & b.Row & ":A" & Range("A" & b.Row).End(xlUp).Row).EntireRow.Delete
        End If
    End If
End Sub

Recuerda cambiar la valoración a la respuesta.

Si funciona! Aunque marca un error en el código "if not b is nothing then" no se por que. Gracias por toda tu ayuda! Me haz ayudado mucho!

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas