macro/ lookup to enter codenumber for when text selected

rajesh84

New Member
Joined
Feb 18, 2010
Messages
29
Hi all,
Back after a long time.

I am trying to setup a drop down list in a cell (with about 25 entries in the look up) and when i select one of them I would like its corresponding code (reference) number to appear in a subsequest cell. For eg- if i select "asfdgehr" from the drop down list, the ref number 1234 should automatically come into another cell.At present i enter each text string,then i look up the corresponding number from a pdf file and then type it in. as you can imagine,pretty hard work !

thanks for your help.
 
Paste this formula in B1 =IF(A1="","",VLOOKUP(A1,Sheet2!A1:B4,2,0))
instead of VLOOKUP(A1,Sheet2!A1:B4,2,0)
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Tried it.

2 problems.

A1, A2 etc- all come up with just "names" on the dropdown list

And an error message "a value is not available for the formula to function"

any suggestions?

thanks
 
Upvote 0
sorry. still the same error.

In sheet 2, my data is a1 to b4, isn't it? I then select a1-4 and name the range.- I also tried a1-b4 as a range but that did not work either.
 
Upvote 0
Ok.
Try in this way...
First select the range which is exist in A column in Sheet2 and named it as NAMES. (only one column) not entire table.

Now , Select A1:A10 column in Sheet1 then Go to-->Data Validation.-->then List---->Then in Source, type =NAMES and press enter.

Then You will get Drop down Symbol at Cell level.
 
Upvote 0
Thanks. that works- to some extent.

The value in b1 comes up right but the values in b2 ,b3 etc comes up with the wrong value (ie, it comes up with the same value as in B1,rather than the value that is supposed to come from b2)

so i tried changing it to =IF(A1="","",VLOOKUP(A1:B4,Sheet2!A1:B4,2,0)) but that came up with a "circular reference error".

Is there a way of telling excel that for A2,it should look at the value in B2 and so on down the column ?

thanks
 
Upvote 0
works now !

but I have to change each cell =IF(A3="","",VLOOKUP(A3,Sheet2!A1:B4,2,0)) etc

so i copied the formula and dragged down the column to paste it and it is working.

is that the only way to do it or is there something simpler ?

thanks
 
Upvote 0
To get accurate result ... fix the table by the symbol $ in range of the table..

=IF(A1="","",VLOOKUP(A1,Sheet2!$A$1:$B$4,2,0))

Now drag the formula to down
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,320
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top