setting up "find and delete row" macro?

D

Doug

I'm using Excel 2000. I've been trying to set up a macro
to perform a loop function: 1) "find next" the occurrence
of a specific text string 2) finding the text string in a
cell, select the entire row 3) delete the entire row 4)
find next occurrence of specific text string and repeat
the process.

So basically, I want to search an entire worksheet for
every occurrence of the string "abc" for example -- and
delete every row with "abc" in it, but leave all rows that
do NOT have "abc" in them.

I've been trying to set up a macro for that, but it's not
working. Maybe I am not setting up the macro correctly?
Or there is a non-macro way to accomplish the same thing?

Thanks in advance for any advice & info!
 
R

Robert Nguyen

-----Original Message-----
I'm using Excel 2000. I've been trying to set up a macro
to perform a loop function: 1) "find next" the occurrence
of a specific text string 2) finding the text string in a
cell, select the entire row 3) delete the entire row 4)
find next occurrence of specific text string and repeat
the process.

So basically, I want to search an entire worksheet for
every occurrence of the string "abc" for example -- and
delete every row with "abc" in it, but leave all rows that
do NOT have "abc" in them.

I've been trying to set up a macro for that, but it's not
working. Maybe I am not setting up the macro correctly?
Or there is a non-macro way to accomplish the same thing?

Thanks in advance for any advice & info!

.

Dim MyRow as Integer
MyRow = 2

Do Until Cells(MyRow, 1).value = ""
If Cells(MyRow, 1).value like "*abc" Then
Rows(MyRow).Delete
MyRow = MyRow - 1
End If
MyRow = MyRow + 1
Loop
 
D

Doug

Hi Robert -

Thanks for the suggestion! I'm not an advanced enough
Excel guy to know where to put this kind of code, but I'll
see if anyone in the office might know. Otherwise, I will
just keep hacking away at it manually.

Thanks again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top