Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Wildcards

Status
Not open for further replies.

tdpman

Technical User
Apr 29, 2002
44
US
I have a column of data that I am trying to clean up. I want to write a macro that will delete the entire row in which this particular column starts with TU. The column is filled with items like TU10, TU15, TU30, etc. I have this so far:

Do Until ActiveCell.Value = ""
If ActiveCell.Value = "TU10" Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Activate
End If
Loop

End Sub

My question is, how can I modify this so that it deletes every row with a TU in this column. How can i incorporate a wildcard so that it will delete TU10, TU11, TU12, TU13, etc.

Thanks for your help!
 
Try,

If Left(ActiveCell.Value,2) = "TU" Then
etc ...

This will remove all rows where that start with "TU" in the given cell.

Andrew C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top