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

Given a starting location but not knowing how many cells will be included (it
varies), is it possible to sum a whole column?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Summing a whole column

Hi Klaus,

Try something like:

Sub Tester()
Dim StartCell As Range
Dim LastCell As Range
Dim mySum As Double

Set StartCell = Range("A10") '<Your known first cell

Set LastCell = Cells(Rows.Count, StartCell.Column).End(xlUp)

mySum = Application.Sum(StartCell, LastCell)

MsgBox mySum

End Sub

---
Regards,
Norman



"Klaus" wrote in message
...
Given a starting location but not knowing how many cells will be included
(it
varies), is it possible to sum a whole column?



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

Thanks Norman, but when I tried this, it only gave me back the last number in
that column. It did not add them all. Any other ideas? What I'm doing right
now is "hardwiring" a value that is beyond the last cell that will be added:
ie SUM(A1:A250).


"Norman Jones" wrote:

Hi Klaus,

Try something like:

Sub Tester()
Dim StartCell As Range
Dim LastCell As Range
Dim mySum As Double

Set StartCell = Range("A10") '<Your known first cell

Set LastCell = Cells(Rows.Count, StartCell.Column).End(xlUp)

mySum = Application.Sum(StartCell, LastCell)

MsgBox mySum

End Sub

---
Regards,
Norman



"Klaus" wrote in message
...
Given a starting location but not knowing how many cells will be included
(it
varies), is it possible to sum a whole column?




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


Klaus,

If you only have values you want to add in a column (e.g. C), you can
try:

=Sum(C:C)

This will add everything in column C.

HTH


--
cparaske
------------------------------------------------------------------------
cparaske's Profile: http://www.excelforum.com/member.php...fo&userid=3793
View this thread: http://www.excelforum.com/showthread...hreadid=379947

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Summing a whole column

Hi Klaus,

Apologies, the line:

mySum = Application.Sum(StartCell, LastCell)


shold have read:

mySum = Application.Sum(Range(StartCell, LastCell))


---
Regards,
Norman



"Klaus" wrote in message
...
Thanks Norman, but when I tried this, it only gave me back the last number
in
that column. It did not add them all. Any other ideas? What I'm doing
right
now is "hardwiring" a value that is beyond the last cell that will be
added:
ie SUM(A1:A250).


"Norman Jones" wrote:

Hi Klaus,

Try something like:

Sub Tester()
Dim StartCell As Range
Dim LastCell As Range
Dim mySum As Double

Set StartCell = Range("A10") '<Your known first cell

Set LastCell = Cells(Rows.Count, StartCell.Column).End(xlUp)

mySum = Application.Sum(StartCell, LastCell)

MsgBox mySum

End Sub

---
Regards,
Norman



"Klaus" wrote in message
...
Given a starting location but not knowing how many cells will be
included
(it
varies), is it possible to sum a whole column?








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Summing a whole column

This solution give a circular reference error.

"cparaske" wrote:


Klaus,

If you only have values you want to add in a column (e.g. C), you can
try:

=Sum(C:C)

This will add everything in column C.

HTH


--
cparaske
------------------------------------------------------------------------
cparaske's Profile: http://www.excelforum.com/member.php...fo&userid=3793
View this thread: http://www.excelforum.com/showthread...hreadid=379947


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Summing a whole column

Thanks Norman, this works well for me.

"Norman Jones" wrote:

Hi Klaus,

Apologies, the line:

mySum = Application.Sum(StartCell, LastCell)


shold have read:

mySum = Application.Sum(Range(StartCell, LastCell))


---
Regards,
Norman



"Klaus" wrote in message
...
Thanks Norman, but when I tried this, it only gave me back the last number
in
that column. It did not add them all. Any other ideas? What I'm doing
right
now is "hardwiring" a value that is beyond the last cell that will be
added:
ie SUM(A1:A250).


"Norman Jones" wrote:

Hi Klaus,

Try something like:

Sub Tester()
Dim StartCell As Range
Dim LastCell As Range
Dim mySum As Double

Set StartCell = Range("A10") '<Your known first cell

Set LastCell = Cells(Rows.Count, StartCell.Column).End(xlUp)

mySum = Application.Sum(StartCell, LastCell)

MsgBox mySum

End Sub

---
Regards,
Norman



"Klaus" wrote in message
...
Given a starting location but not knowing how many cells will be
included
(it
varies), is it possible to sum a whole column?






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Summing a whole column

Put the formula in a different cell outside column C (maybe D1?)



Klaus wrote:

This solution give a circular reference error.

"cparaske" wrote:


Klaus,

If you only have values you want to add in a column (e.g. C), you can
try:

=Sum(C:C)

This will add everything in column C.

HTH


--
cparaske
------------------------------------------------------------------------
cparaske's Profile: http://www.excelforum.com/member.php...fo&userid=3793
View this thread: http://www.excelforum.com/showthread...hreadid=379947



--

Dave Peterson
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 02:31 PM.

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"