matching items on 2 sheets

J

JT

I'm having some problems with the code below. "Range" is
a range name for the items in column A on sheet 2.

I want to look in column A on sheet 1 and if there is a
match in the range (Column A - sheet 2), then I want to
delete the row on Sheet 1 where the match occurs


Sheets("1").Activate

Dim rngToSearch
Dim rngToFind As Range
Dim rngFound As Range

Set rngToSearch = Sheets("2").Range("Range")

For Each rngToFind In rngToSearch

Set rngFound = Sheets("1").Cells.Find(rngToFind.Value)

Do While Not rngFound Is Nothing

rngFound.EntireRow.Delete
Set rngFound = Sheets("1").Cells.Find.
(rngToFind.Value)

Loop

Next rngToFind

Any help would be greatly appreciated. Thanks........
 
G

Guest

Sorry whe I wrote that code for you I was obviously a little off. The A's and
B's were apparently more that I could fathom...

Give me a few minutes to think about this...
 
G

Guest

Dim rngToFind As Range
Dim rngFound As Range

Set rngToFind = Sheets("1").Range("A65535").End(xlup)
do while rngToFind.row > 1
Set rngFound = Sheets("2").Columns(1).Find(rngToFind.Value)
if not rngFound is nothing then rngToFind.EntireRow.Delete
set rngtofind = rngtofind.offset(-1,0)
loop
 
J

JT

Jim..........Thanks for the help. I'll give this a
try........Do you have any suggestions for a good
reference book that could help me with things like this?
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