Wild Card!!!???

G

Guest

I have the following macro, I am trying to use the * behind the cell criteria
to delete as a wild card! Is there a way to do this, basically the cells
that I want to delete have these characters in them and other characters
behind it, so I wanted to put a wild card at the end? Any Help...

Sub Foo_Test1356()

Dim rng As Range
Dim cll As Range
Dim x As Long

x = 0
Set rng = ActiveSheet.Range("A1:A10000")
For Each cll In rng.Cells
If cll.Text = "----*" _
Or cll.Text = "000*" _
Or cll.Text = "For acct*" Then
cll.EntireRow.Delete
x = x + 1
End If
Next cll

MsgBox "Deleted " & x & " rows."

End Sub
 
F

Franz Verga

Sean said:
I have the following macro, I am trying to use the * behind the cell
criteria to delete as a wild card! Is there a way to do this,
basically the cells that I want to delete have these characters in
them and other characters behind it, so I wanted to put a wild card
at the end? Any Help...

Sub Foo_Test1356()

Dim rng As Range
Dim cll As Range
Dim x As Long

x = 0
Set rng = ActiveSheet.Range("A1:A10000")
For Each cll In rng.Cells
If cll.Text = "----*" _
Or cll.Text = "000*" _
Or cll.Text = "For acct*" Then
cll.EntireRow.Delete
x = x + 1
End If
Next cll

MsgBox "Deleted " & x & " rows."

End Sub

Hi Sean,

I think you could use the Left$ function:

----------------

If Left$(cll.Text, 4) = "----" _
Or Left$(cll.Text, ) = "000" _
Or Left$(cll.Text, 8) = "For acct" Then

----------------




--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy
 
G

Guest

you need to use the word "Like" instead of the equal sign.

if cll.text like "----*" Or cll.Text Like "000*" Or cll.Text like "For
acct*" Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top