AutoSum Syntax

M

MikeTunny

I have created a Macro which loops down a single colum to find the nex
empty cell, I then used the following syntax to select all the dat
that I have looped through;

ActiveCell.Offset(-1, 0).Select

Range (Selection, Selection.End(xlUp)).Select

I now need to auto Sum that data so it apears in my empty Cell at th
bottom. Is there code I can use to produce an automatic AutoSum??? O
is there another solution? Can I use R1C1 style to paste in a formul
that has variable colum sizes?

Please help

Mike Tunstal
 
T

Tom Ogilvy

with the first cell at the top of the column to sum as the active cell

Sub AABBD()
Dim rng As Range
Set rng = Range(ActiveCell, ActiveCell.End(xlDown))

rng.Offset(rng.Rows.Count, 0).Resize(1, 1).Formula = _
"=Sum(" & rng.Address(0, 0) & ")"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top