Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Member
 
Posts: 89
Post Macro to run SUM function

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
JCO JCO is offline
external usenet poster
 
Posts: 54
Default Macro to run SUM function

=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




--
frankjh19701

  #3   Report Post  
Member
 
Posts: 89
Post

Thank you for the reply.

I was looking to use the SUM function inside a Macro and have the 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 the result in a sheet titled "Totals".

Please let me know your thoughts.

Thank you

Quote:
Originally Posted by JCO View Post
=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




--
frankjh19701
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macro to run SUM function

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.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Member
 
Posts: 89
Post

Thank you Claus.

How would I start the Macro in VBA?

What's the correct wording?


  #6   Report Post  
Member
 
Posts: 89
Post

I've tried it a number of ways and cannot get it to work.
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macro to run SUM function

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.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #8   Report Post  
Member
 
Posts: 89
Post

Thank you, Claus.

That worked!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MACRO FUNCTION conflict with other macro's MrDave Excel Discussion (Misc queries) 3 July 19th 09 12:25 PM
Using A Function in a Macro Jai_Friday Excel Worksheet Functions 2 March 13th 08 01:18 PM
Not sure what function, macro, etc to use Tony Excel Worksheet Functions 2 January 6th 08 06:10 PM
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM


All times are GMT +1. The time now is 10:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"