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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create maco button for Average like SUM

Status
Not open for further replies.

MSUser

Technical User
Oct 31, 2000
33
0
0
US
I need to create a maco buttom to insert the Average function just like the SUM function(default) button. I know how to create the macro buttom and assign the macro, but cannot get the correct VBA syntax for selecting the range of cells for average function. I want to select the cells like I do by clicking the SUM button and selecting the cells to SUM. Thanks.
 
Maybe i,m missing something here but,...why not just type

=average(cell_ref:cell_ref)

,..where "cell_ref" is the range you select by "blocking" cells with your mouse?
 


ActiveCell.FormulaR1C1 = "=AVERAGE(r[0]c[0]:r[0]c[0])"
End Sub

Here's the VBA syntax I have so far. I want it to show AVERAGE() so I can select the range for averaging after i click the macro button.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top