Sum number of rows

bh24524

Active Member
Joined
Dec 11, 2008
Messages
322
Office Version
  1. 365
  2. 2007
Is there some kind of formula that can sum an amount or rows based on a number you type in? Like if for example, I want to sum only 50 rows one time, 300 another, 1000 yet another and so on is there some way I can do this without having to highlight different sections to see totals? Ideally if I could just type in 50 and it sums the first 50 rows in a specified column and then the same for any other number that is typed in. It would always start from the top.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You beat me to it. INDIRECT is another way

BH24524.xlsx
BCDEFG
111Rows to SumINDIRECTOFFSET
2227308308
333
444
555
666
777
888
999
10111
Sheet1
Cell Formulas
RangeFormula
F2F2=SUM(INDIRECT("$B1:$B"&D2))
G2G2=SUM(OFFSET($B$1,,,D2))
 
Upvote 0
You beat me to it. INDIRECT is another way

BH24524.xlsx
BCDEFG
111Rows to SumINDIRECTOFFSET
2227308308
333
444
555
666
777
888
999
10111
Sheet1
Cell Formulas
RangeFormula
F2F2=SUM(INDIRECT("$B1:$B"&D2))
G2G2=SUM(OFFSET($B$1,,,D2))
Thank you for that though definitely. I wondered if INDIRECT could somehow be used for it. I am not familiar with INDIRECT so this will be something cool to play around with to. Thanks for sharing that!
 
Upvote 0
You could also avoid the volatile function OFFSET (& INDIRECT)

Excel Formula:
=SUM(B1:INDEX(B:B,D1))
That's a cool one. Wouldn't have thought of that. Gonna play around with that one too. Thank you!

EDIT: the result was actually coming out different that the Offset or Indirect formulas. In one instance, I was summing only 12 rows which had a value of 10 in each row(that one was the easy one) so that should come out to 120 but using the mentioned formula, it came to 110. I used
Excel Formula:
=sum(A2:index(A:A,D1))
I do have one for the column B as well but A was easier since it was all values of 10. Did I do something wrong?
 
Last edited:
Upvote 0
That's a cool one. Wouldn't have thought of that. Gonna play around with that one too. Thank you!

EDIT: the result was actually coming out different that the Offset or Indirect formulas. In one instance, I was summing only 12 rows which had a value of 10 in each row(that one was the easy one) so that should come out to 120 but using the mentioned formula, it came to 110. I used
Excel Formula:
=sum(A2:index(A:A,D1))
I do have one for the column B as well but A was easier since it was all values of 10. Did I do something wrong?
Nevermind I see what I did wrong I should not have a header in the row
 
Upvote 0
Your original example was summing from row 1 & now apparently you are not. Try something like this for a non-volatile version if data actually starts in row 2.
This is better anyway in that it now doesn't matter if rows are subsequently added or deleted.

20 12 12.xlsm
ABCDEF
1DataRowsSum
21012120
310
410
510
610
710
810
910
1010
1110
1210
1310
1410
1510
Sum
Cell Formulas
RangeFormula
F2F2=SUM(B2:INDEX(B:B,D2+ROW(B2)-1))


Or another option would be something like
Excel Formula:
=SUM(B2:INDEX(B2:B1000,D2))
 
Upvote 0
... or if you have Excel 365 {I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)}

20 12 12.xlsm
ABCDEF
1DataRowsSum
21012120
310
410
510
610
710
810
910
1010
1110
1210
1310
1410
1510
Sum
Cell Formulas
RangeFormula
F2F2=SUM(INDEX(B2:B1000,SEQUENCE(D2)))
 
Upvote 0
... or if you have Excel 365 {I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)}

20 12 12.xlsm
ABCDEF
1DataRowsSum
21012120
310
410
510
610
710
810
910
1010
1110
1210
1310
1410
1510
Sum
Cell Formulas
RangeFormula
F2F2=SUM(INDEX(B2:B1000,SEQUENCE(D2)))
Got it and I edited the profile. Thank you it is working now.
 
Upvote 0

Forum statistics

Threads
1,215,593
Messages
6,125,715
Members
449,254
Latest member
Eva146

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