Multiple IF functions with Formulas within one cell.

Hughes

New Member
Joined
Jan 11, 2011
Messages
8
Example:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
<TABLE style="WIDTH: 426pt; BORDER-COLLAPSE: collapse; mso-padding-alt: 0in 0in 0in 0in" class=MsoNormalTable border=0 cellSpacing=0 cellPadding=0 width=568 u1:str><COLGROUP><COL style="WIDTH: 48pt; mso-width-source: userset; mso-width-alt: 2340" span=2 width=64><COL style="WIDTH: 14pt; mso-width-source: userset; mso-width-alt: 694" width=19><COL style="WIDTH: 48pt; mso-width-source: userset; mso-width-alt: 2340" span=2 width=64><COL style="WIDTH: 14pt; mso-width-source: userset; mso-width-alt: 694" width=19><COL style="WIDTH: 48pt; mso-width-source: userset; mso-width-alt: 2340" span=3 width=64><COL style="WIDTH: 14pt; mso-width-source: userset; mso-width-alt: 694" width=19><COL style="WIDTH: 48pt; mso-width-source: userset; mso-width-alt: 2340" width=64><TBODY><TR style="HEIGHT: 12.95pt; mso-height-source: userset; mso-yfti-irow: 0; mso-yfti-firstrow: yes"><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64><o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64>A<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 14pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=19><o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64>C<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64>D<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 14pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=19><o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64>F<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64>G<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64>H<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 14pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=19><o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; WIDTH: 48pt; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" width=64>J<o:p></o:p>

</TD></TR><TR style="HEIGHT: 12.95pt; mso-height-source: userset; mso-yfti-irow: 1; mso-yfti-lastrow: yes"><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in" u1:num>1<o:p></o:p>



</TD><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt">A<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in"><o:p></o:p>

</TD><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt" u1:num>72<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt" u1:num>48<o:p></o:p>



</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in"><o:p></o:p>


</TD><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt">NO<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt">NO<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-top-alt: solid windowtext .5pt; mso-border-bottom-alt: solid windowtext .5pt; mso-border-right-alt: solid windowtext .5pt">YES<o:p></o:p>


</TD><TD style="BORDER-BOTTOM: #e0dfe3; BORDER-LEFT: #e0dfe3; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: #e0dfe3; BORDER-RIGHT: #e0dfe3; PADDING-TOP: 0in"><o:p></o:p>

</TD><TD style="BORDER-BOTTOM: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; PADDING-BOTTOM: 0in; BACKGROUND-COLOR: transparent; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; HEIGHT: 12.95pt; BORDER-TOP: windowtext 1pt solid; BORDER-RIGHT: windowtext 1pt solid; PADDING-TOP: 0in; mso-border-alt: solid windowtext .5pt" u1:num>702<o:p></o:p>



</TD></TR></TBODY></TABLE>
<o:p></o:p>
I want J to say:<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = NO) & (H1 = NO) then ((C1 + D1)*4.85) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = YES) & (G1 = NO) & (H1 = NO) then ((C1 + D1)*5.15) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = YES) & (H1 = NO) then ((C1 + D1)*5.55) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = NO) & (H1 = YES) then ((C1 + D1)*5.85) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = YES) & (G1 = YES) & (H1 = NO) then ((C1 + D1)*5.85) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = YES) & (H1 = YES) then ((C1 + D1)*6.55) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = YES) & (G1 = YES) & (H1 = YES) then ((C1 + D1)*6.85) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = NO) & (H1 = NO) then ((C1 + D1)*5.15) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = YES) & (G1 = NO) & (H1 = NO) then ((C1 + D1)*5.45) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = YES) & (H1 = NO) then ((C1 + D1)*5.85) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = NO) & (H1 = YES) then ((C1 + D1)*6.15) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = YES) & (G1 = YES) & (H1 = NO) then ((C1 + D1)*6.15) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = NO) & (G1 = YES) & (H1 = YES) then ((C1 + D1)*6.85) or<o:p></o:p>
<o:p></o:p>
IF (A1 = A) & (F1 = YES) & (G1 = YES) & (H1 = YES) then ((C1 + D1)*7.15) or.............................<o:p></o:p>
<o:p></o:p>
And so on through A1 = N. I would also want to extend the options in F-H to F-P. Help is much appreciated.<o:p></o:p>
<o:p></o:p>
I've wanted to do something like this on Access as I've seen a coworker with something similar. Unfortunately I've never used Access and need to get this going sooner than I could learn. <o:p></o:p>
 
Could I have the value for Column A hidden off the worksheet. For eample, I would have a drop down In A1 that would pull from a list of Series A, Series B, Series C, Series D, etc that's hidden. Then I could have a formula hidden in another cell that says IF A1 = Series A then the base for J is 4.85. IF A1 = Series B then the base for J is 5.15.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Could I have the value for Column A hidden off the worksheet. For eample, I would have a drop down In A1 that would pull from a list of Series A, Series B, Series C, Series D, etc that's hidden. Then I could have a formula hidden in another cell that says IF A1 = Series A then the base for J is 4.85. IF A1 = Series B then the base for J is 5.15.

I don't think you need to do that, msg#11 incorporates it all in one cell.
 
Upvote 0
I'm not getting an error message but the answer is "0" regardless of what I have in A1. I added the values for I1 & J1 but still "0".
 
Upvote 0
Working formulae:
Copy down the formulae in L1,M1 and N1.
The three formulae all give the same result, but those in columns M and N will be shorter once you extend it to handle more possibilities in column A. These shorter formulae depend on the first letter of the cell in column A being the series name (upper or lower case, it doesn't matter).
Just choose whichever of the three you're comfortable with.
Excel Workbook
ABCDEFGHIJKLMN
1A7248NONONONONO582582582
2A7248NONOYESNONO702702702
3A7248NOYESNONONO666666666
4A7248NOYESYESNONO786786786
5A7248YESNONONONO618618618
6A7248YESYESNONONO702702702
7A7248YESYESYESNONO822822822
8B7248NONONONONO618618618
9B7248NONOYESNONO738738738
10B7248NOYESNONONO702702702
11B7248NOYESYESNONO822822822
12B7248YESNONONONO654654654
13B7248YESYESNONONO738738738
14B7248YESYESYESNONO858858858
Sheet
 
Upvote 0
PERFECT. Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You saved me countless hours! I wan't even close to heading in the right direction!
 
Upvote 0
You might be interested in another if the YESses and NOs in column F:J (or F:N whatever) are always next to each other (no gaps between columns):
Excel Workbook
ABCDEFGHIJWY
1A7248NONONONONO582
2a7248NONOYESNONO702
3about7248NOYESNOYESNO720
4A7248NOYESYESNONO786
5A7248YESNONONONO618
6A7248YESYESNOYESNO756
7A7248YESYESYESNONO822
8B7248NONONONOYES696
9B7248NONOYESNONO738
10bills7248NOYESNOYESNO756
11B7248NOYESYESNONO822
12b7248YESNONOYESYES786
13B7248YESYESNONONO738
14B7248YESYESYESNOYES936
Sheet


where the
{0.3,0.7,1,0.45,0.65}
corresponds to columns F:J

and the
4.85,5.15,6.3
corresponds to "A","B" or "C" etc. in column A


And if you were prepared to put the values in row 1 (then hide it) you could simplify further:
Excel Workbook
ABCDEFGHIJWZ
10.30.710.450.65
2A7248NONONONONO582
3a7248NONOYESNONO702
4about7248NOYESNOYESNO720
5A7248NOYESYESNONO786
6A7248YESNONONONO618
7A7248YESYESNOYESNO756
8A7248YESYESYESNONO822
9B7248NONONONOYES696
10B7248NONOYESNONO738
11bills7248NOYESNOYESNO756
12B7248NOYESYESNONO822
13b7248YESNONOYESYES786
14B7248YESYESNONONO738
15B7248YESYESYESNOYES936
Sheet


And still further shorten it if you were to have a lookup table for the Series (A,B, C, D etc,) as MrKowz suggested in msg#2.
 
Last edited:
Upvote 0
Even Better. One question so I can learn. What is the "-64" in the formula? Where does that particular number come from? And one question for aesthetics. Is there any way to make what is Y and Z in your column appear simply blank or "0" until information is entered. This way when the blacnk workbook is opened there isn't a "#VALUE!" error?
 
Upvote 0
Even Better. One question so I can learn. What is the "-64" in the formula? Where does that particular number come from? And one question for aesthetics. Is there any way to make what is Y and Z in your column appear simply blank or "0" until information is entered. This way when the blacnk workbook is opened there isn't a "#VALUE!" error?
CODE("A") is 65
CODE("B") is 66
CODE("C") is 67
etc.
subtract 64 from each and you get 1,2,3 etc. which is used in the CHOOSE function.

Hiding errors:
pre xl2007:
=if(iserror(the_formula),"",the_formula)

xl2007 onwards:
iferror(the_formula,"")

where the_formula is whichever of the formulae you've opted for.
 
Upvote 0
I was just passing by....

re hiding errors - it is important to note that error masking like (using iferror() etc)that hides all errors, including those generated as a result of dodgy formula syntax. this can be a bad thing, especially when you've got complex formulas to work with.

e.g.

=if(iserror(sm(a1:a10),"No sales, so someone's getting fired",sum(a1:a10))

...is not an error you'd want to mask.
 
Upvote 0
While replying to your question on the origins of -64 in the equation, I noticed I made a mistake in the formula in M1 of msg#14, it should have included the INDEX function, so I've shown it below in M1, corrected.

While I'm at it, take a look at the short formula in L2, this is to show you how to use a lookup table, which will mean however many columns F:? you want to use and however many series A,B,C etc. you want to use, the formula will get no longer than the one in L2 below. It has the additional benefit, that a changing any of the values in the lookup table, or any of the values in (the hidden) row 1, will immediately be reflected in all the calculations, so you won't have to set about editing lots of formulae to correct a mistake.

The green area is the look up table which I named SeriesTable. This doesn't have to be on the same sheet, and can be anywhere in the workbook.
Excel Workbook
ABCDEFGHIJKLM
10.30.710.450.65
2A7248NONONONONO582582
3a7248NONOYESNONO702702
4a7248NOYESNOYESNO720720
5a7248NOYESYESNONO786786
6A7248YESNONONONO618618
7A7248YESYESNOYESNO756756
8A7248YESYESYESNONO822822
9B7248NONONONOYES696696
10B7248NONOYESNONO738738
11b7248NOYESNOYESNO756756
12B7248NOYESYESNONO822822
13b7248YESNONOYESYES786786
14B7248YESYESNONONO738738
15B7248YESYESYESNOYES936936
16
17
18A4.85
19B5.15
20C6.3
21D6.75
22E7
23F7.1
24G7.2
25H7.3
26I7.4
27J7.5
28K7.6
29L7.7
30M7.8
31N7.9
32
Sheet
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,847
Members
449,194
Latest member
HellScout

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