find and copy cells

R

rishi

suppose i hav two sheets as follows...
SHEET 1
ID location country

1 211
2 315
3 234
4 146
5 254
6 147
7 631
8 942
9 845
10 413



and sheet 2 as
id name customer location region

1 211 steve ford onsite usa
2 315 alex nissan offshore india
3 631 white gm onsite usa
4 146 rishi tata onshore india
5 254 john ford offshore india
6 147 bill ford offshore india
7 295 george nissan onshore usa
8 942 enayan gm onshore usa
9 845 mike tata offshore usa
10 413 ali gm onsite india
11 456 murray gm onsite usa
12 486 tim tata offshore india
13 546 david tata onsite inida
14 896 micheal nissan onsite usa
15 234 alison nissan onsite france


now i have to search sheet2 and fill up sheet 1 with the corresponding
entries....both the sheets are in the same workbook...
if someone can help me it would be great...
 
S

Smallweed

use Vlookup rather than a macro, eg in sheet1, location column:
=vlookup(A1,sheet2!A1:E65000,4,FALSE)
 
M

Mike H

It's not easy to see exacly how your data are laid out so I've made some
assumptions.

ID on sheet1 is in column A and your data in sheet2 are in columns A to E
and Location is in column 4 and country is in column 5. So try:-

=VLOOKUP(A2,Sheet2!A2:E16,4,FALSE) placed in B2 sheet1 to return loc
=VLOOKUP(A2,Sheet2!A2:E16,5,FALSE) placed in C2 sheet1 to return city

etc

Mike
 
D

Don Guillett

Use VLOOKUP or a macro that uses FIND to find the id in the source sheet and
get the .value from the offset cells. Something like: UN tested
for each c in range("idrange")
with sheets("source")
x=.columns(1).find(c).row
..cells(x,2).resize(,3).copy cells(c.row,2)
end with
next c
 

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