Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum at end of data?


I have a spreadsheet with numbers. I really need a code snippet that
will go the bottom the data and sum all values in that column.

My guess is that the code would need to loop through the cells to
detect any missing values...once it finds a missing value, sum
everything above it.

Thanks in advance for any help you can provide!


--
gkimmer
------------------------------------------------------------------------
gkimmer's Profile: http://www.excelforum.com/member.php...o&userid=22882
View this thread: http://www.excelforum.com/showthread...hreadid=532153

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Sum at end of data?

maybe something like this, assuming column a and data starting in row 1

Sub add_column()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lastrow + 1).Formula = "=sum(A1:A" & lastrow & ")"
End Sub

--


Gary


"gkimmer" wrote in
message ...

I have a spreadsheet with numbers. I really need a code snippet that
will go the bottom the data and sum all values in that column.

My guess is that the code would need to loop through the cells to
detect any missing values...once it finds a missing value, sum
everything above it.

Thanks in advance for any help you can provide!


--
gkimmer
------------------------------------------------------------------------
gkimmer's Profile:
http://www.excelforum.com/member.php...o&userid=22882
View this thread: http://www.excelforum.com/showthread...hreadid=532153



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum at end of data?


Here are 2 ways

the first finds the last used row in column A then places the sum
formula in the next row

The 2nd finds the last used row in any column then places the sum
formula in the next row in column A

Sub SumColumn()
Dim lRow As Long
lRow = Cells(Rows.Count, "a").End(xlUp).Row
Cells(lRow + 1, "a").Value = "=sum(a3:a" & lRow & ")"
End Sub


Sub SumColumn()
Dim lRow As Long
lRow = Cells.Find(What:="*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row

Cells(lRow + 1, "a").Value = "=sum(a3:a" & lRow & ")"
End Sub


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=532153

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
Data Labels- POssible to show data value and data label together? kippers Charts and Charting in Excel 1 April 1st 09 01:33 PM
Increase Your Business By Data Conversion, Data Format and Data EntryServices in India Data Entry India Excel Worksheet Functions 1 March 31st 08 12:51 PM
Save 20% On Data Conversion and Data Formats Services by Data EntryIndia Data Entry India Excel Discussion (Misc queries) 0 March 31st 08 12:00 PM
Data Entry Online, Data Format, Data Conversion and Data EntryServices through Data Entry Outsourcing [email protected] Excel Discussion (Misc queries) 0 March 20th 08 12:45 PM
MULTIPLE DATA - How to insert new data into existing data.... Rodorodo Excel Discussion (Misc queries) 0 December 15th 06 11:50 PM


All times are GMT +1. The time now is 02:11 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"