Sum dynamic range

sfran

New Member
Joined
Mar 9, 2021
Messages
24
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I'm trying to sum a range of cells starting from "B8" to a variable end row in the same column. I have tried various ways to try to accomplish this, but seems to keep failing. I would like to have the cell 2 rows below the end of this range to show the total. The code I am currently using is:

Sheets(Sheets.Count).Cells(featsummaryrow, 2) = Application.Sum(Range(Cells(8, 2), Cells(featsummaryrow - 2, 2)))

In other tests I have done, the Sheets(Sheets.Count).Cells(featsummaryrow, 2) portion is properly working (just had it equal to a number and it populates correctly). It seems my trouble is with the "summation" side of the equation. Have tried using .formula and other methods... i'm still doing something wrong.

Any insight is appreciated.

Thanks!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,640
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
With Sheets(Sheets.Count)
   .Cells(featsummaryrow, 2) = Application.Sum(.Range(.Cells(8, 2), .Cells(featsummaryrow - 2, 2)))
End With
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
63,640
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,143,673
Messages
5,720,223
Members
422,270
Latest member
CaptainMurray

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