Hey Charlie,
I made the minimal changes to your existing procedure to handle filtering
the string of *'s you indicated. I include a wildcard * on either side of
the string so that that string can appear anywhere in the cells:
Sub DeleteRows()
Dim i As Long, Criteria As String
' put a tilde before each "wildcard" character to treat literally
Criteria = "*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~**"
i = Range("B" & Rows.Count).End(xlUp).Row
With Range("B5:B" & i)
If Application.WorksheetFunction.CountIf(Columns(2), Criteria) > 0
Then
.AutoFilter field:=1, Criteria1:=Criteria
.Offset(1).Resize(.Rows.Count - 1, 1).EntireRow.Delete
.AutoFilter
End If
End With
End Sub
Note that this won't delete the first row, because the first row is treated
as a header row by AutoFilter.
Asa
From: [email protected] [mailto:[email protected]]
On Behalf Of Cab Boose
Sent: Friday, April 06, 2012 1:06 AM
To: [email protected]
Subject: $$Excel-Macros$$ Deleteing Rows based on single column contents
Hi
In worbook attached I am deleting rows based on contents of column C.
When I use as it is set up at the moment it works as it should and deletes
rows with SETOUTS in them. That is good.
However, in a second similiar macro, I also want to delete rows that have
in column C this : *************** but as it is a wildcard
character I am having difficulty to get it to work. Usually deletes most of
the sheet. How do I tell in the macro that the last asterix is the wild
card and that previous asterix are what is in the cell ? and that is a row
to delete.
A similiar thing is there are a lot of rows that have 6 spaces and then some
text, text varies and unknown. I have tried putting in 6 spaces and * (
*) or (* ) like that but to know available. how do you allow for
spaces preceding unknown text ?
A model railroad project.
Thanks and regards
Charlie
--
FORUM RULES (986+ members already BANNED for violation)
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security
measure.
4) Acknowledge the responses you receive, good or bad.
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited.
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
----------------------------------------------------------------------------
--------------------------
To post to this group, send email to [email protected]
--
FORUM RULES (986+ members already BANNED for violation)
1) Use concise, accurate thread titles. Poor thread titles, like Please Help,
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited.
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
------------------------------------------------------------------------------------------------------
To post to this group, send email to [email protected]