PDA

View Full Version : Sum of Cells Within the Selected Range (vba)



abuzainab73
07-27-2010, 04:25 AM
By vba code :


How do I get the sum of cells within a selected range by pressing on the macro button , so that the result in cell A1 for example.

Bob Phillips
07-27-2010, 04:36 AM
Why bother, you can see it in the statusbar, bottom right.

Simon Lloyd
07-27-2010, 04:43 AM
xld is right it will serve you no purpose!, but, Range("A1").Value = Application.WorksheetFunction.Sum(Selection)

abuzainab73
07-27-2010, 11:36 AM
Simon Lloyd ,
thanks alot
Because I need the result to be in the active cell changed the code to the following:

ActiveCell.value= Application.WorksheetFunction.Sum(Selection)




the underlined was the part that i can't make it .


so, again thank you very much.