Hi,
I am trying to create a maro to get the sum of a column... however the range of the column is not specified .. to i need to check till the end of the column and then add them
Hi,
I am trying to create a maro to get the sum of a column... however the range of the column is not specified .. to i need to check till the end of the column and then add them
=SUM(A:A)
will sum everything in column A, no need to specify the end.
its giving a "Compiler error"
It's not VBA, VBA is overkill for that.
If you must VBA
[vba]
MsgBox Application.Sum(Range("A:A"))
[/vba]
I need to display the result in the column which is empty.. not in the form of a mesgbox
Can't you work that out yourself, don't you know any VBA?
ANd why not just a formula direct in the worksheet?
Try:
[VBA]
Option Explicit
Sub Column_sum()
Dim Rng As Range
Dim MyVal As Integer
Set Rng = ActiveSheet.Range("A1").End(xlDown)
MyVal = Application.WorksheetFunction.Sum(ActiveSheet.Range("A1:" & Rng.Address))
Rng.Offset(1, 0).Value = MyVal
End Sub
[/VBA]it will put the sum at the bottom of each column , but from this code you will be able to work out how to send the value to another location!
regards,
Simon
Regards,
Simon
Please read this before cross posting!
In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
If I have seen further it is by standing on the shoulders of giants.
Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)
Thanks .. that helped a lot