Thread
:
Add Sum to the columns at the last row
View Single Post
#
5
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Add Sum to the columns at the last row
This sums c7:v? whatever the last row in col C is. Does it below last row in
col C
Sub sumcolc()
lr = Cells(Rows.Count, "c").End(xlUp).Row
Cells(lr + 1, "c").Formula = "=sum(c7:v" & lr & ")"
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"vivi" wrote in message
...
Hi there, I am using this code here but it doesn't give me the result I
desire as I have a 36 months starting from Column V and data starts at row
7.
The problem is that the starting point is always the same, but my end
point
varies depending the number of entries. I would like to add a formula to
the
end of each month.
The code I am using is:
Sub Marco()
Dim lastrow2 As Range
ActiveWorkbook.Names.Add Name:="lastrow4", _
RefersToR1C1:=ActiveSheet.Cells(Rows.Count, "C").End(xlUp)
Set lastrow2 = ActiveSheet.Cells(Rows.Count, "C").End(xlUp). _
Offset(1, 0)
lastrow2.FormulaR1C1 = "=SUM(R7C10:lastrow4)"
End Sub
Instead of calculating the column itself, it calculates from the start
point
to the last cell that has a number
Can you help please?
Thanks a lot
Viv
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett