using sum function after offset
Thank you all for the help!!!!
"Tom Ogilvy" wrote:
Looks like I had a typo:
Sub AddSum()
Dim rng As Range
Set rng = Cells(Rows.Count, ActiveCell.Column).End(xlUp)(2)
If rng.Row 8 Then
rng.FormulaR1C1 = "=Sum(R8C:R[-1]C)"
End If
End Sub
--
Regards,
Tom Ogilvy
"Tom Ogilvy" wrote:
Assuming you want the sum in the activecolumn and the top number to sum is in
row 8:
Sub AddSum()
Dim rng as Range
set rng = cells(rows.count,activecell.column).end(xlup)(2)
if rng.row 8 then
rng.FormulaR1C1 = "=Sum(R8C:R[-1]C)"
end Sub
End Sub
--
Regards,
Tom Ogilvy
"Annoyed Accountant" wrote:
This has got to be easier than I am making it. I need (via VBA) to locate the
end of a column of numbers, go one below the numbers (a blank cell) and enter
a formula that will calculate the sum of the numbers above. Since the amount
of data changes, this is what I have so far:
Range("D8").Select ' this is where my data starts (absolute reference)
Selection.End(xlDown).Select ' goes to last cell of data
Cells.Offset(0, 1).Select ' goes down one cell from that
Now, how do I enter sum(d8:?) How do I refer to the offset cell without
using absolute references in my formula? I tried using a macro, but excel
automatically used absolute references. Thanks in advance for the help. This
shouldn't be difficult!
|