Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Summing a column | Excel Worksheet Functions | |||
summing column c based an column a criteria | Excel Worksheet Functions | |||
Summing a Column instead of a Column range | Excel Discussion (Misc queries) | |||
Summing one column based on date in another column | New Users to Excel | |||
Summing a column | Excel Worksheet Functions |