Variable Sum Up Problem

manthony

New Member
Joined
Dec 5, 2016
Messages
40
Hi,

This is an odd formula I am looking for. I have a formula to get me to the last row in column D. I would then like to sum from the last row in col. D up X number of rows. The X is determined by a count formula on a different sheet titled duplicates.

My problem is the sum range is variable and will always be in column D but the summing row starting position (last row in column D) and number of rows to be summed (# counted on the duplicates sheet) are variable. Below is an example of what I am looking for.

Duplicates count = 5

Col./Rows
A
B
C
D
E
F
1
2
3
3
5
4
7
5
11
6
8
7
= leave one row blank
8
34
=sum formula
9

<tbody>
</tbody>

Many thanks for the help.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
How about to try INDIRECT function?

=SUM(INDIRECT("D"&(your last row formula)-(your count formula)&":D"&(your last row formula)))
 
Last edited by a moderator:
Upvote 0
Hi thanks for the help. Sorry, I was not clear. My last row formula is vba code that selects to last row in column D. My count formula is COUNTA(Duplicates!B:B)-1). Any ideas on how to combined it with your formula?
 
Upvote 0
If you are using vba, do the all job there. You can try something like:

Code:
Dim count As Integer
count = [COLOR=#000080][FONT=&quot]Evaluate("[/FONT][/COLOR][COLOR=#333333]COUNTA(Duplicates!B:B)-1)[/COLOR][COLOR=#000080][FONT=&quot]")[/FONT][/COLOR]
Sheets("Sheet1").[C1].Formula ="=SUM(D"&lastRow-count&":D"&lastRow&")"
 
Upvote 0
Thanks, but I am getting an expected end of statement error on the last line on the last ":D" section.
 
Upvote 0
I would like to enter the formula in column D after the last row with a value in it.

If you want it enter after the blank row following the last data row...

=SUM(OFFSET(INDEX(D:D,ROW()-2),0,0,-5))

where you can replace 5 with the cell housing your count.

Outside D, say in E1, you could invoke the following formula:

=SUM(OFFSET(INDEX(D:D,MATCH(9.99999999999999E+307,D:D)),0,0,-5))

Again, here also you can replace 5 with the cell housing that number.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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