Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone know VBA syntax for Excel SUM button? 1

Status
Not open for further replies.

MSUser

Technical User
Oct 31, 2000
33
US
I would like to change it to AVERAGE
 
Hi,
Code:
x = Application.SUM(MyRange)
y = Application.AVERAGE(MyRange)
Hope this helps :)
Skip,
SkipAndMary1017@mindspring.com
 
What is your syntax? - please include all. Skip,
SkipAndMary1017@mindspring.com
 

ActiveCell.Offset(0, 0).Range("A1").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-12]C:R[-1]C)"
End Sub
 

Range("A1").Value = Application.Average(YourRange)

puts the value in the cell and

Range("A1").Formula= "=Average(" & YourRange.Address & ")"

puts a formula in the cell

Skip,
SkipAndMary1017@mindspring.com
 
Thanks for your help,but how can I get it work just like the SUM button; where the it seeks the cell (closest numbe value(s)) to average.
 
I don't think you can. I use the SUM button and then F2 (edit) to change the SUM to AVERAGE. You could write a macro to do that and put it on another button. But what's the point? The SUM button is designed for initial set-up. What is the underlying requirement you are trying to meet?

BTW, if you haven't tried it yet, you can click the sum button twice for the (almost) same effect as clicking it once followed by the enter key. The only difference is the selection stays on the cell with SUM formula and does not auto-advance (assuming auto-advance is active).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top