How to Sum Data in Columns using a formula for the column

grantmt

New Member
Joined
Mar 16, 2011
Messages
2
Hi,

I would like to sum the data in mulitple columns -in this case b4 through aj4.
However, I would like to use a formula that sums the data based on an input value, where the value input equals the final column used in the sum.

Example: if I input a 2 into cell AN6, I would like a formula in AN7 that sums column b4 through c4. If I put a 3 into cell AN6, AN7 returns the sum of the value in columns b4 through d4.

I am using excel 2010.

There are multiple rows (200) that I will perform this function on, so I would rather not define a range for each row.

Thanks in advance for assistance
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You can use INDEX

Code:
AN7:
=SUM($B4:INDEX($B4:$IV4,$AN$6))

You could also use OFFSET but this would be Volatile

Code:
AN7:
=SUM(OFFSET($B4,0,0,1,$AN$6))
 
Upvote 0
The Index function works perfectly. Thank you very very much. I use Excel every day but have never used Index.
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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