Macro to run SUM function

F

frankjh19701

Can anyone tell me how to create a Macro that performs the SUM functio
in a selected worksheet?

Any/all assistance is greatly appreciated.

Thank yo
 
J

JCO

=SUM(A32:A44)
Put this in the space where you want the total to be. This example sums
everything in A32 to A44. Use any range you need.



"frankjh19701" wrote in message


Can anyone tell me how to create a Macro that performs the SUM function
in a selected worksheet?

Any/all assistance is greatly appreciated.

Thank you
 
F

frankjh19701

Thank you for the reply.

I was looking to use the SUM function inside a Macro and have th
results populate into a different sheet within the same workbook.

For example:

Macro to fins sum of Column M in Sheet named Bass-1 and return th
result in a sheet titled "Totals".

Please let me know your thoughts.

Thank you
 
C

Claus Busch

Hi Frank,

Am Wed, 6 Nov 2013 17:54:25 +0000 schrieb frankjh19701:
Macro to fins sum of Column M in Sheet named Bass-1 and return the
result in a sheet titled "Totals".

try:

With Sheets("Bass-1")
LRow = .Cells(Rows.Count, "M").End(xlUp).Row
Sheets("Totals").Range("A2") = _
WorksheetFunction.Sum(.Range("M:M"))
End With

or:

Sheets("Totals").Range("A1").Formula = _
"=Sum('Bass-1'!" & Range("M:M").Address & ")"

Regards
Claus B.
 
F

frankjh19701

Thank you Claus.

How would I start the Macro in VBA?

What's the correct wording
 
C

Claus Busch

Hi Frank,

Am Wed, 6 Nov 2013 20:08:09 +0000 schrieb frankjh19701:
How would I start the Macro in VBA?

e.g. you have this code in a standard module:

Sub Test2()
Dim LRow As Long

With Sheets("Bass-1")
LRow = .Cells(Rows.Count, "M").End(xlUp).Row
Sheets("Totals").Range("A2") = _
WorksheetFunction.Sum(.Range("M:M"))
End With
End Sub

so you can run the macro from the sheet => Macros => Test2 => Run


Regards
Claus B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top