LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default deleting rows based on criteria

I am copying a text file into excel (all one column A) from a database and
want to delete rows that have the following information:
the date for example 08/14/2008 followed by QMS Log Page 69 of 79 (this will
of course be 1 of 79 etc). I have tried to use some of the threads seen in
this discussion group in a macro but with no luck. My attempt is
Sub testme02()

Dim MyRng As Range
Dim FoundCell As Range
Dim wks As Worksheet
Dim myStrings As Variant
Dim iCtr As Long

myStrings = Array("QMS Log Page") 'add more strings if you need

Set wks = ActiveSheet

With wks
Set MyRng = .Range("a2:a" & .Rows.Count)
End With

For iCtr = LBound(myStrings) To UBound(myStrings)
Do
With MyRng
Set FoundCell = .Cells.Find(what:=myStrings(iCtr), _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireRow.Delete
End If
End With
Loop
Next iCtr
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows based on multiple criteria [email protected] Excel Programming 0 January 11th 07 07:40 PM
Deleting entire rows based on certain criteria Nan[_4_] Excel Programming 1 July 12th 04 05:04 PM
Deleting rows based on multiple criteria Sandip Shah Excel Programming 3 July 12th 04 01:57 PM
Deleting rows based on cell criteria jgranda Excel Programming 1 April 27th 04 06:41 PM
Deleting rows based on criteria John Walker[_2_] Excel Programming 2 December 12th 03 08:37 PM


All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"