Forum Discussion

InTh0ught's avatar
InTh0ught
Copper Contributor
Dec 14, 2024

Modifying Delete Row based on Extract from Text

Column A has two repeating rows that need to be removed. Column A contains:

column1

total amount

I am not proficient enough to modify the following to delete these rows

Sub DeleteRows()
Dim iLastRow As Long
Dim i As Long
    iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    Rows(1).EntireRow.Delete
    For i = iLastRow To 1 Step -1
        If Cells(i, "A").Value = "" Then
            Rows(i).Delete
        End If
    Next i
End Sub

Appreciate the help

 

L

  • Does this do what you want?

    Sub DeleteRows()
        Dim iLastRow As Long
        Dim i As Long
        Application.ScreenUpdating = False
        iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
        For i = iLastRow To 1 Step -1
            If Cells(i, "A").Value = "column1" Or Cells(i, "A").Value = "total amount" Then
                Rows(i).Delete
            End If
        Next i
        Application.ScreenUpdating = True
    End Sub

     

Resources