Nesting 12 if functions, How?

Amy from Charlotte

New Member
Joined
Mar 10, 2003
Messages
4
I am trying to nest 12 if functions with no success, I have read several other posts regaring this and have tried some of the suggested formulas but still can't get it to work right, please help! :rolleyes:

Here is the formula:
=(IF($AF$74=1,B78,"")&IF($AF$74=2,SUM(B78:C78),"")&IF($AF$74=3,SUM(B78:D78),"")&IF($AF$74=4,SUM(B78:E78),"")&IF($AF$74=5,SUM(B78:F78),"")&IF($AF$74=6,SUM(B78:G78),"")&IF($AF$74=7,SUM(B78:H78),"")&IF($AF$74=8,SUM(B78:I78),"")&IF($AF$74=9,SUM(B78:J78),"")&IF($AF$74=10,SUM(B78:K78,"")))

So the idea is that if cell equals 1 then return a value, if cell equals 2 then sum 2 values and return, if cell equals 3 then sum 3 values and return. When I enter the formula above I get a #VALUE error. What am I doing wrong?

Thanks!!! :rolleyes: :rolleyes:
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
You are better off setting up a table with your data and creating a LOOKUP formula instead.
 

KenWright

Active Member
Joined
Jan 14, 2005
Messages
267
=SUM(OFFSET(B78,,,AF74))

Addendum

As Oaktree pointed out I had missed a comma - Grrrrrr - Serves me right for just typing it and not trying it. :oops:

=SUM(OFFSET(B78,,,,AF74))
 

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,021
Office Version
  1. 365
Try = sum(B78:eek:ffset(B78,0,$af$74-1))

edit: I like Ken's more, but I think his should have 4 commas instead of 3

=SUM(OFFSET(B78,,,,AF74))
 

shades

Well-known Member
Joined
Mar 20, 2002
Messages
1,550

ADVERTISEMENT

The reason it isn't working, is that the & operator makes it text not number, even though it looks like a number.
 

Forum statistics

Threads
1,147,675
Messages
5,742,546
Members
423,737
Latest member
tom_xls

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
Top