LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to delete rows with different data

Hey, that looks familiar!

Ron de Bruin wrote:

Here is another one from Dave that use find with a inputbox
http://www.rondebruin.nl/delete.htm#Find

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

"Dave Peterson" wrote in message ...
One way:

Option Explicit
Sub testme02()

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

myStrings = Array("D", "GL", "NO", "REPO", "RUN")

Set wks = ActiveSheet

With wks
Set myRng = .Range("a3: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



Tasha wrote:

I need a macro to find data in cell column 1, starting in cell A3 that
contains the data "D", "GL", "NO", "REPO" and "RUN". I need it to find these
cells, and if that cell contains any of the noted data above, to delete the
entire row. Can someone help me with this? I've tried using some of the
macros mentioned in this forum, but was only for one variable, and I wasn't
sure how to do it with multiple variables????

Any help appreciated!!!


--

Dave Peterson


--

Dave Peterson


 
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
Macro to delete blank rows in a data range Youlan Excel Discussion (Misc queries) 5 September 17th 08 08:51 AM
Macro to delete rows containing specific data Slohcin New Users to Excel 2 December 20th 06 11:52 AM
delete data rows in excel by using a macro? Marcia Excel Programming 3 July 25th 06 10:33 PM
Macro to delete rows with same data Connie Martin Excel Worksheet Functions 12 November 22nd 05 01:18 PM
delete rows using macro when no data in column Derek Chambers Excel Programming 1 October 21st 04 12:22 PM


All times are GMT +1. The time now is 02:49 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"