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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Rows containing specific words - MS Excel.

Status
Not open for further replies.

Jayz

ISP
Feb 17, 2002
59
0
0
This is doing my brain in.
I need to be able to delete rows on an entire sheet that contain specific words eg a row/s containing the words 'Mat' & 'Delta' regardless what cell it is in. It could be in some instances more than 2 words.

I'm curretly only able to delete according to one word.

Heres a script I found:
===========
Sub Find_Mat()
Dim rng As Range
Dim Mat As String

word = "Mat"

Do
Set rng = ActiveSheet.UsedRange.Find(word)


If rng Is Nothing Then

Exit Do
Else
Rows(rng.Row).Delete
End If


Loop
End Sub
===============

Would really appreciate some help.

Thanks,
Jay
 
Typed, untested:
Code:
Do
  Set rng = ActiveSheet.UsedRange.Find("Mat")
  If rng Is Nothing Then Exit Do
  Set rng = rng.EntireColumn.Find("Delta")
  If Not (rng Is Nothing) Then Rows(rng.Row).Delete
Loop

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks for the attempt PHV, tried your code but ended up in the loop of death.

any other ideas?
 
Sorry for the typo:
Set rng = rng.Entire[!]Row[/!].Find("Delta")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top