LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Add Sum to the columns at the last row

This will use col C as the longest row and put the sum formula for c:H.
Modify to suit
If c is not the longest row, use another.

Sub sumcolc()
lr = Cells(Rows.Count, "c").End(xlUp).Row
Cells(lr + 1, "c").Resize(, 6).Formula = _
"=sum(c1:c" & lr & ")"

End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
button to seach columns for blank cells, then sort by two columns plfiredis Excel Programming 1 April 29th 08 02:32 PM
Help in code Steve G wrote to move data from 4 columns to 21 columns Steve G Excel Programming 9 August 2nd 07 02:43 PM
to convert columns to rows having mulit independent group columns Quacy Excel Worksheet Functions 1 August 22nd 06 11:20 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 2 July 31st 06 09:45 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 0 July 31st 06 05:07 PM


All times are GMT +1. The time now is 09:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"