View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default If Statement with Wildcards not Working

Try the below

For i = 672 To 1 Step -1
If Cells(i, "J") Like "*UASGN*" Then Rows(i & ":" & i).Delete
Next i

If this post helps click Yes
---------------
Jacob Skaria


"cr0375" wrote:

I'm trying to make delete all rows that contain the text "UASGN" in column J.
I have tried a few different methods based upon research from this site, but
I'm having an issue with each one. The one I think I'll use is this:

For i = 1 To 672
If Cells(i, "J") = "*UASGN*" Then
Rows(i & ":" & i).Select
Selection.Delete Shift:=xlUp
i = i - 1 ' as we just deleted a row, we should not increase i
End If
Next i

When I use this, it appears to have a problem with the wildcards. If I
remove the wildcards and replace with a finite character(s), it works.

Thanks.