Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

STL - Formerly Best Training Solutions Through Learning
TrustPilot
Excellent
Request Callback We will call you back
0207 987 3777 Call for assistance
Your Basket Basket is empty
autosum

ResolvedVersion 2007

Ross has attended:
Excel VBA Intro Intermediate course

AutoSum

Hi

After running a macro i want to put a sum at the bottom but the problem is that the area could change each time

the current formula is

range("D7").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C:R[-1]C)"

This will only sum 12 Rows. The amount of row will vary
how can tell how many rows it needs to Sum.

RE: AutoSum

Hi Ross, have a look in our commented code for how we used currentregion.rows.count and then use that to cope with your fluctuating numbers of rows.

Hope this helps,

Anthony

Fri 2 Mar 2012: Automatically marked as resolved.

Excel tip:

Using basic functions without doing formulas

When you highlight figures Autocalc tells you the total in the bottom right of the screen, but if you right click on the sum it will give you some basic functions. The functions are Min, Max, Average, Sum, Count, and Count Nums.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.