How to read and find a name?

T

Tom

Hi,

Column 1 Sheet1 carries a list of names:
David
Susan
Kathie
John
etc.

Column 1 Sheet2 carries another list:
Jack
Susan
Fred
David
Sam
etc.

How do you write a macro to read David in Sheet1 then goes to find it in
Sheet2?
Perform a task, then returns to Sheet1, comes down 1 row to read Susan and
goes back to Sheet2, to find Susan and performs the same task. Repeat the
process until it reads a blank name in Sheet1 and stops. Thank you for any
help.

TIA
Tom
 
D

Don Guillett

Simplest version. NO need to goto the other sheet

sub loopeach()
for each n in sheet1.range("a1:a21")
msgbox sheet2.find(n,columns(1).row
next n
end sub
 
T

Tom

Excel 2003 doesn't like the line:
msgbox sheet2.find(n,columns(1).row
It says, "Syntax Error"
Thanks Don.

Tom
 
D

Don Guillett

Haste make waste. Still TOO simple but you get the idea

Excel 2003 doesn't like the line:
msgbox sheet2.columns(1).find(n).row
It says, "Syntax Error"
Thanks Don.
 
T

Tom

Can't it be done automatically without the use of a message box?
Sheet 1 holds the names of say 50 people whose weekly wages will go up by
7.5% recorded in Sheet 2 - the task to be performed. I then want to replace
the list in Sheet 1 with 250 other names whose wages will be going up by 5%
and so on.
 
D

Don Guillett

The msgbox was just to show you how it works. You would replace that with
what you want to do.
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.
 

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