Trueblue862
Board Regular
- Joined
- May 24, 2020
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
Hi,
I have this piece of code which finds the value "Del" in column "M" and if that value is present it deletes that row, it works perfectly but I need it to loop until there are no cells with "Del" in them. I'm just not sure how to set it up with a Do Until loop function. Any help with this would be appreciated.
I have this piece of code which finds the value "Del" in column "M" and if that value is present it deletes that row, it works perfectly but I need it to loop until there are no cells with "Del" in them. I'm just not sure how to set it up with a Do Until loop function. Any help with this would be appreciated.
VBA Code:
Private Sub BtnDel_Click()
Sheets("Mail Merge").Activate
iSelected = ("Del")
lR = Cells(Rows.Count, "M").End(xlUp).Row
Set rData = Range("M2:M" & lR).Find(iSelected, LookIn:=xlValues, lookat:=xlWhole)
If rData Is Nothing Then: Exit Sub
ans = rData.Row
Rows(ans).EntireRow.Delete
End Sub