Hi All.
I want to have a macro search a worksheet and delete said rows everytime a keyword is found in that column.
Example: delete all rows when the keyword "swap" is found.
The keyword is constant & will only be found in column "C" in worksheet "PV".
I have attached my code for review and modification.
Thanks in advance for any & all help.
Sub Test()
Delete1Row ("swap"
End Sub
Sub Delete1Row(swap)
Const COL_TEST = 1 ' Column "C"
Dim nRow As Long
Dim nLastRow As Long
Dim sRowsToDelete As String
With ActiveSheet.UsedRange
nLastRow = .Rows.Count + .Row - 1
End With
For nRow = 1 To nLastRow
If Cells(nRow, COL_TEST) = swap Then
sRowsToDelete = nRow & ":" & (nRow + 0)
Range(sRowsToDelete).EntireRow.Delete
End If
Next nRow
End Sub
I want to have a macro search a worksheet and delete said rows everytime a keyword is found in that column.
Example: delete all rows when the keyword "swap" is found.
The keyword is constant & will only be found in column "C" in worksheet "PV".
I have attached my code for review and modification.
Thanks in advance for any & all help.
Sub Test()
Delete1Row ("swap"
End Sub
Sub Delete1Row(swap)
Const COL_TEST = 1 ' Column "C"
Dim nRow As Long
Dim nLastRow As Long
Dim sRowsToDelete As String
With ActiveSheet.UsedRange
nLastRow = .Rows.Count + .Row - 1
End With
For nRow = 1 To nLastRow
If Cells(nRow, COL_TEST) = swap Then
sRowsToDelete = nRow & ":" & (nRow + 0)
Range(sRowsToDelete).EntireRow.Delete
End If
Next nRow
End Sub