If Statement Issue - Excel

kathleen0927

New Member
Joined
Feb 7, 2018
Messages
32
Hello all!

I am having difficulty using multiple IF statements in 1 cell. There are 8 options the IF statement needs to check which are:
if J9 = BB, insert "1" in cell B9
if J9 = OS, insert "2" in cell B9
if J9 = OST, insert "3" in cell B9
if J9 = VP, "4"
if J9 = RR, "5"
if J9 = A3, "6"
if J9 = OD,"7"
if J9 = TN, "8"

This formula will be in all cells in column B of the Excel file for sorting. Any suggestions for how to write this? Thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Excel 2010
BCDEF
1
2BB1
3OS2
4OST3
5VP4
6RR5
7A36
8OD7
98TN8
108
118
2b
Cell Formulas
RangeFormula
B9=VLOOKUP(J9,E2:F9,2,0)
B10=VLOOKUP(J9,{"BB",1;"OS",2;"OST",3;"VP",4;"RR",5;"A3",6;"OD",7;"TN",8},2,0)
B11=IF(J9="BB",1,IF(J9="OS",2,IF(J9="OST",3,IF(J9="VP",4,IF(J9="RR",5,IF(J9="A3",6,IF(J9="OD",7,IF(J9="TN",8,""))))))))
 
Upvote 0
Kathleen0927,
There is also a 9th option you need to consider and that is what if none of the eight options are inputted into J9?
Computerman
 
Upvote 0
I am confused by cells B10 and B11. What do they do? For every row in column "B", the formula will need to insert a number 1 - 8
 
Upvote 0
I am confused by cells B10 and B11. What do they do? For every row in column "B", the formula will need to insert a number 1 - 8
He is just showing you three different ways to do it. All three are different formulas, but will return the same thing.
The first one uses a lookup table (similar to my recommendation).
The other two are formulaic solutions that do not require a lookup table, as all posssible values are right there in the formulas.

One advantage to using a lookup table is that is you set it up correctly, you can easily make edits to the table values without having to update any formulas.
 
Upvote 0

Forum statistics

Threads
1,216,736
Messages
6,132,426
Members
449,727
Latest member
Aby2024

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