Problems with nested IF functions

CrampedHands

New Member
Joined
Sep 30, 2011
Messages
2
Hi, I've poked around here a few times when I've need some help but couldn't find the answer to this one lurking in the shadows.

I'm using the formula, =IF(A2=9,A3,IF(A3>9,A4,IF(A4>9,A5,IF(A5>9,A6,IF(A6>9,5))))) to get the 2nd row to look like the one in the last sample. When I run the formula it doesn't make it past the first row, I've tried everything I can think of.The "9" and "5" is just to give me some values to sort with.

Thanks in advance!! I've been wasting some serious time on this...

Excel Workbook
AB
1Customerform2
29
39
49
59
61000 ABC INC
79
89
91001 ABEL
109
111002 ACT INC
129
131003 ADM CO
Sheet1
Excel Workbook
AB
1Customerform2
299
399
499
591000 ABC INC
61000 ABC INC9
799
891001 ABEL
91001 ABEL9
1091002 ACT INC
111002 ACT INC9
1291003 ADM CO
131003 ADM CO9
Excel 2010 Failed Example
Excel 2010
Cell Formulas
RangeFormula
B2=IF(A2=9,A3,IF(A3>9,A4,IF(A4>9,A5,IF(A5>9,A6,IF(A6>9,5)))))
B3=IF(A3=9,A4,IF(A4>9,A5,IF(A5>9,A6,IF(A6>9,A7,IF(A7>9,5)))))
B4=IF(A4=9,A5,IF(A5>9,A6,IF(A6>9,A7,IF(A7>9,A8,IF(A8>9,5)))))
B5=IF(A5=9,A6,IF(A6>9,A7,IF(A7>9,A8,IF(A8>9,A9,IF(A9>9,5)))))
B6=IF(A6=9,A7,IF(A7>9,A8,IF(A8>9,A9,IF(A9>9,A10,IF(A10>9,5)))))
B7=IF(A7=9,A8,IF(A8>9,A9,IF(A9>9,A10,IF(A10>9,A11,IF(A11>9,5)))))
B8=IF(A8=9,A9,IF(A9>9,A10,IF(A10>9,A11,IF(A11>9,A12,IF(A12>9,5)))))
B9=IF(A9=9,A10,IF(A10>9,A11,IF(A11>9,A12,IF(A12>9,A13,IF(A13>9,5)))))
B10=IF(A10=9,A11,IF(A11>9,A12,IF(A12>9,A13,IF(A13>9,A14,IF(A14>9,5)))))
B11=IF(A11=9,A12,IF(A12>9,A13,IF(A13>9,A14,IF(A14>9,A15,IF(A15>9,5)))))
B12=IF(A12=9,A13,IF(A13>9,A14,IF(A14>9,A15,IF(A15>9,A16,IF(A16>9,5)))))
B13=IF(A13=9,A14,IF(A14>9,A15,IF(A15>9,A16,IF(A16>9,A17,IF(A17>9,5)))))




Excel Workbook
AB
1Customerform2
291000 ABC INC
391000 ABC INC
491000 ABC INC
591000 ABC INC
61000 ABC INC5
791001 ABEL
891001 ABEL
91001 ABEL5
1091002 ACT INC
111002 ACT INC5
1291003 ADM CO
131003 ADM CO5
Desired Example
Excel 2010
Cell Formulas
RangeFormula
B5=IF(A5=9,A6,IF(A6>9,A7,IF(A7>9,A8,IF(A8>9,A9,IF(A9>9,5)))))
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi,

Here's an option to try (in B2 and drag down):

=IF(ISNUMBER(A2),INDEX(A2:$A$13,MATCH(0,--ISNUMBER(A2:$A$13),0)),5)

or

=IF(A2=9,INDEX(A2:$A$13,MATCH(1,--(A2:$A$13<>9),0)),5)

These are array formulae, so use CTRL-SHIFT-ENTER rather than just ENTER.
 
Last edited:
Upvote 0
Odd formula, but once you copy it all the way down it will present properly.

Excel Workbook
AB
1Customerform2
291000 ABC INC
391000 ABC INC
491000 ABC INC
591000 ABC INC
61000 ABC INC5
791001 ABEL
891001 ABEL
91001 ABEL5
1091002 ACT INC
111002 ACT INC5
1291003 ADM CO
131003 ADM CO5
Sheet2
 
Upvote 0
Awesome!! That worked! Thanks jbeaucaire.

I tried the other formula as well by I must admit I don't even know what an array formula is. I can only do the basics... :(

I've got to watch some YouTube videos or something, I was stuck on that the whole day...
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

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