ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Wild Card!!!??? (https://www.excelbanter.com/excel-programming/371872-wild-card.html)

Sean

Wild Card!!!???
 
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


Franz Verga

Wild Card!!!???
 
Sean wrote:
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



Peter T

Wild Card!!!???
 
Look at ' Like ' in VBA help.

Regards,
Peter T


"Sean" wrote in message
...
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




Mike

Wild Card!!!???
 
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


"Peter T" wrote:

Look at ' Like ' in VBA help.

Regards,
Peter T


"Sean" wrote in message
...
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






All times are GMT +1. The time now is 02:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com