ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Summing a whole column (https://www.excelbanter.com/excel-programming/332055-summing-whole-column.html)

Klaus

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?

Norman Jones

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?




Klaus

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?





cparaske[_4_]

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


Norman Jones

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?







Klaus

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



Klaus

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?







Dave Peterson

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


All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com