variable sum formula

DanKokoro

New Member
Joined
Dec 14, 2009
Messages
27
Hi all,

Have a question relating to a variable sum formula. I did a fair amount of searching online but couldn't find an answer to my problem. Would be very appreciative of any help. Here goes.

I am after a formula, that will do a vertical lookup and then sum a variable number of cells to the right.

E.G.
In row 2 i have the 12 months starting at B2.
In Column A i have product codes starting at A3, they are sequential and are as follows 001,002,003,004 etc..

In cell A1 i have a variable product code
In cell A2 i have a variable number which designates how many months (1-12) . i.e. if the number in A2 is 2 it means two months (Jan and Feb), if the number is 4 it means 4 months (Jan, Feb, Mar, April).

for example if A1 is "0003" and A2 is 4, i want a formula that will look down to find "0003" which will be in A5 and then sum A6,A7,A8,A9.

I'm sorry if my explanation/examples are not as helpful as they could be. But i'd really appreciate some help on this because i've been stuck for ages on this one...

Thanks so much in advance..
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try...

=SUM(INDEX($B$3:$B$200,MATCH(A1,$A$3:$A$200,0)):INDEX($B$3:$M$200,MATCH(A1,$A$3:$A$200,0),A2))

where A1 houses a product of interest and A2 number of months.
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,550
Members
452,927
Latest member
rows and columns

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