Multiple If statements ..... any alternative

lynxbci

Board Regular
Joined
Sep 22, 2004
Messages
201
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi,
I have an if statement in a cell which returns a value based on another cell, and without using a lookup table is there a simpler way to get the same result?
Current formula is :-
<code>
=IF(G20="PET",1,IF(G20="PVC",7,IF(G20="SAP",12,IF(G20="TTT",99,0))))
</code>
thanks in advance
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,
I have an if statement in a cell which returns a value based on another cell, and without using a lookup table is there a simpler way to get the same result?
Current formula is :-
<CODE>
=IF(G20="PET",1,IF(G20="PVC",7,IF(G20="SAP",12,IF(G20="TTT",99,0))))
</CODE>
thanks in advance
"Is there a simpler way" is a relative concept!

IMHO, what you already have is pretty simple.
 
Upvote 0
Not without either:
1. Using a lookup table
2. Hard Coding the lookup into the formula

Hard coding it in the formula

=LOOKUP(G20,{"PET",1;"PVC",7;"SAP",12;"TTT",99})

Note, the Text strings must be in alphabetical order left to right.
 
Upvote 0
Not without either:
1. Using a lookup table
2. Hard Coding the lookup into the formula

Hard coding it in the formula

=LOOKUP(G20,{"PET",1;"PVC",7;"SAP",12;"TTT",99})

Note, the Text strings must be in alphabetical order left to right.
That leaves out the value_if_false result of 0 if the none of the values are found.
 
Last edited:
Upvote 0
Alternatives might be:-
  • use =LOOKUP where the array is defined in the formula but this is not good if the formula exists in multiple cells and there's a possibility that the lookup values might change in the future
  • use a UDF: this will make the worksheet formula much simpler but it would add the requirement for macros to be enabled and involve an additional skill (understanding VBA)
You pays your money and you takes your choice!
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,283
Members
452,902
Latest member
Knuddeluff

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