Macro that analyses 3 columns and put results in 4th

A

andrei

Example :

A1: 1
A2: 2
A3: 3
A4: 4
A5: 5

B1 : Andrew
B2 : John
B3 : Smiley
B4: Irene
B5 : Obama

C1 : 2
C2 : 2
C3 : 1
C4 : 5
C5: 3

The result should be this :

D1: John
D2: John
D3: Andrew
D4: Obama
D5: Smiley

Macro reads C column from the first cell (C1) . Finds "2" . Goes to A column
where it finds "2" in cell A2 . For 2 in A column coresponds "John" in B
column . So , in D1 puts "John "

And so on ....

Numbers from A column do not repeat ( are from 1 to n )
Numbers from C column repeat
 
L

Lars-Åke Aspelin

Example :

A1: 1
A2: 2
A3: 3
A4: 4
A5: 5

B1 : Andrew
B2 : John
B3 : Smiley
B4: Irene
B5 : Obama

C1 : 2
C2 : 2
C3 : 1
C4 : 5
C5: 3

The result should be this :

D1: John
D2: John
D3: Andrew
D4: Obama
D5: Smiley

Macro reads C column from the first cell (C1) . Finds "2" . Goes to A column
where it finds "2" in cell A2 . For 2 in A column coresponds "John" in B
column . So , in D1 puts "John "

And so on ....

Numbers from A column do not repeat ( are from 1 to n )
Numbers from C column repeat

Try the following formula in cell D1:

=INDEX(B$1:B$5,C1)

copy down to cell D5.

Change the 5 to something else if you have more rows of data.

Hope this helps / Lars-Åke
 
A

andrei

Thanks , it works !

Lars-Ã…ke Aspelin said:
Try the following formula in cell D1:

=INDEX(B$1:B$5,C1)

copy down to cell D5.

Change the 5 to something else if you have more rows of data.

Hope this helps / Lars-Ã…ke
 
A

andrei

I actually found a problem

It works only for numbers from 1 to 9 . For numbers from 10 and beyond gives
error #REF!
 
J

Jacob Skaria

Try the below and copy down. In the other post Lars has mentioned to adjust
the rnage to suit...

=INDEX(B:B,C1)

If this post helps click Yes
 

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