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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,223,705
Messages
6,173,986
Members
452,541
Latest member
haasro02

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