Changing cell based on set value

Justastarted

New Member
Joined
Aug 1, 2018
Messages
4
I'm trying to have a table where if you enter a letter in one cell it will give a number in a different cell. So if A1=A then B2=1, if A1=B then B2=2. I've written a formula in colum B something like this:
=If(A1="A",1,(if(A1="b",2,if(A1="c" etc......
I have about 20-40 different codes to go through and the formula is getting rediculous. It works the way I want it to, but is there an easier way to do what I'm trying to do?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
You could make a table on a separate sheet. Column A has the letters Column B the corresponding numbers and use vlookup.
 
Upvote 0
Put your 2-column table somewhere with the 1st column being what will show up in A1 and the 2nd column what you want depending on A1.

Then, use VLOOKUP to populate your B column.

Code:
=VLOOKUP(A1,$F$1:$G$100,2,false)

where, for example, F1:G100 contains the table you reference.

This has NO error checking if the value in your A column doesn't exist in the table.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,749
Members
449,050
Latest member
excelknuckles

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