Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Summing a column in a macro

I would like to sum a column in a macro I have recorded. It would start
at the same cell (G9) everytime but the length of the column will vary
from day to day. I would like to put the sum in the first available
cell at the end of the column. What would be the best way to
accomplish this. Thank you in advance.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Summing a column in a macro

Try this

Dim cRows As Long

cRows = Cells(Rows.Count, "G").End(xlUp).Row
Cells(cRows + 1, "G").FormulaR1C1 = "=SUM(R9C:R" & CStr(cRows) & "C)"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gfinch" wrote in message
...
I would like to sum a column in a macro I have recorded. It would start
at the same cell (G9) everytime but the length of the column will vary
from day to day. I would like to put the sum in the first available
cell at the end of the column. What would be the best way to
accomplish this. Thank you in advance.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Summing a column in a macro

Bob,
Thanks for the help. Works like it should. I appreciate the help all
of you give through this forum. Keep up the good work.
Gib



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Summing a column in a macro

Thanks Gib, your feedback is appreciated.

Bob

"gfinch" wrote in message
...
Bob,
Thanks for the help. Works like it should. I appreciate the help all
of you give through this forum. Keep up the good work.
Gib



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Summing a column in a macro

Try something like:

Sub sumColumn()

Dim firstRow As Long
Dim lastRow As Long
Dim aColumn As Integer

aColumn = 7 'Column G
firstRow = 9
lastRow = Cells(65536, aColumn).End(xlUp).Row

If lastRow = firstRow Then _
Cells(lastRow + 1, aColumn) = _
"=SUM(R" & firstRow & "C:R" & lastRow & "C)"

End Sub

This assumes that there is no total already entered (or
else the existing total would be included in the new
total).

Tim



-----Original Message-----
I would like to sum a column in a macro I have recorded.

It would start
at the same cell (G9) everytime but the length of the

column will vary
from day to day. I would like to put the sum in the

first available
cell at the end of the column. What would be the best

way to
accomplish this. Thank you in advance.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from

http://www.ExcelForum.com/

.

Reply
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
Summing a column Rooky228 Excel Worksheet Functions 6 May 14th 09 10:41 PM
summing column c based an column a criteria ndforty Excel Worksheet Functions 2 May 3rd 07 06:57 PM
Summing a Column instead of a Column range SharonP. Excel Discussion (Misc queries) 1 February 16th 06 07:28 PM
Summing one column based on date in another column excel guru i'm not New Users to Excel 7 December 30th 05 08:39 PM
Summing a column Al Ramirez Excel Worksheet Functions 3 August 13th 05 04:46 AM


All times are GMT +1. The time now is 10:21 AM.

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

About Us

"It's about Microsoft Excel"