Need help with amending code, please

L

Lee Jeffery

Using Excel 97 on WINNT.

I need to use VBA to find the first blank cell at the bottom of colum
G and then total the column values. I'm sure this is really basic stuf
but I'm way before basic!

I found some code which is:
Sub QuickTotals()
r = ActiveCell.CurrentRegion.Rows.Count
Set SumRow = ActiveCell.CurrentRegion.Offset(r, 0).Resize(1)
SumRow.FormulaR1C1 = "=SUM(R[" & -r & "]C:R[-1]C)"
SumRow.Offset(0, -1).Resize(1, 1).Value = "Totals"

End Sub

but this is totalling the whole range of columns. I've tried amending
few things but keep getting different sorts of Run-time errors becaus
I don't really know what I'm doing.

Could someone please steer me in the right direction?

Thank you.

Lee.:confused
 
D

Don Guillett

If you are trying to sum from the active cell in G to the last value in G
and put that value below, then try this
Sub sumG()
x = Cells(Rows.Count, "g").End(xlUp).Row
Cells(x + 1, "G") = Application.sum(Range(Cells( _
ActiveCell.Row, "g"), Cells(x, "g")))
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