Hi Community,
I have this macro that I modified from a previous post. The macro finds a text , in this case, "ABC" and, then from this active cell down to the last cell, it deletes entire rows that contains a value of "1" or "2"
At the moment, the text "ABC" is located in column G but sometimes it is located in another column.
Ideally this macro will operate from the active cell down to the last row (yes, there are black cells down the range). At the moment I have locked column ":g" in the macro below. However, sometimes is column "p" or any other column. Would someone please assist to make this part dynamic? Much appreciated!!
I have this macro that I modified from a previous post. The macro finds a text , in this case, "ABC" and, then from this active cell down to the last cell, it deletes entire rows that contains a value of "1" or "2"
At the moment, the text "ABC" is located in column G but sometimes it is located in another column.
Ideally this macro will operate from the active cell down to the last row (yes, there are black cells down the range). At the moment I have locked column ":g" in the macro below. However, sometimes is column "p" or any other column. Would someone please assist to make this part dynamic? Much appreciated!!
VBA Code:
Sub DeletefromActiveCell()
LastRow = Cells(Rows.Count, "d").End(xlUp).Row
Range("a1:r200").Select
Selection.Find(what:="ABC", LookIn:=xlValues).Select
For Each Cell In Range(ActiveCell.Address & ":g" & LastRow)
If Cell.Value = "1" Or Cell.Value = "2" Then
Cell.EntireRow.Delete
End If
Next
End Sub