Hi everyone,
I'm new to excel VBA and would like some help with a specific issue.
I have a worksheet with variable columns and rows.
I need to find multiple strings in each cell of the sheet and delete the entire row if any of the values are found
I was trying to adapt something like this:
But don't know how.
Can anyone help?
Thanks!
I'm new to excel VBA and would like some help with a specific issue.
I have a worksheet with variable columns and rows.
I need to find multiple strings in each cell of the sheet and delete the entire row if any of the values are found
I was trying to adapt something like this:
VBA Code:
Sub deleteRow()
Dim MyValue As String
Dim strValueToRemove As Variant
strValueToRemove = Array("Value1", "Value2", "Value3", "Value4")
For Each cell In ActiveSheet.UsedRange.Cells
MyValue = CStr(cell.Value)
For a = 1 To 6
If InStr(1, MyValue, strValueToRemove(a), vbTextCompare) > 0 Then
cell.EntireRow.Delete
Exit For
End If
Next
Next cell
End Sub
But don't know how.
Can anyone help?
Thanks!