Hey there!
I'm struggling with some code I found on another site (here:How to remove rows based on cell value in Excel?)
The code works when I specify a specific value but I'd like to use cell.value like "*something*"
For some reason this code doesn't seem to work...
Sub Delete_Rows()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("A6:A20"), ActiveSheet.UsedRange)
For Each cell In rng
If cell.Value Like "*word I want to match*" _
Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Sub
Any help much appreciated!
Thanks,
Claire
I'm struggling with some code I found on another site (here:How to remove rows based on cell value in Excel?)
The code works when I specify a specific value but I'd like to use cell.value like "*something*"
For some reason this code doesn't seem to work...
Sub Delete_Rows()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("A6:A20"), ActiveSheet.UsedRange)
For Each cell In rng
If cell.Value Like "*word I want to match*" _
Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Sub
Any help much appreciated!
Thanks,
Claire