I know that the sum function shortcut key is Alt + =, but is there a similar shortcut for the average function? If not, is there an easy way to create one? Thank you.
I know that the sum function shortcut key is Alt + =, but is there a similar shortcut for the average function? If not, is there an easy way to create one? Thank you.
Well, the ALT+= shortcut is not exactly for the function, it's for the autosum button, which happens to populate the cell with the function SUM. There is a subtle difference. There are not shortcuts for functions as such.
I thought it would be straightforward to write a macro that would do what you want, then assign a shortcut key to it, but when I run the macro the line
generates an error (1004, application-defined or object-defined error). I suspect that VBA might not be allowed to insert a function that a user would not be able to legally insert (i.e., AVERAGE without its arguments).![]()
Please Login or Register to view this content.
So I don't know of any way to do this.
It's "reasonably" straight forward to do this..
In your ThisWorkbook's Workbook_Open event, paste the following code:
Then insert a standard module and paste this code:![]()
Please Login or Register to view this content.
Finally, in the Workbook_BeforeClose event, add this to reset the key combo to nothing:![]()
Please Login or Register to view this content.
Save and close, then re-open the workbook. (Or, just run the workbook_open event manually from the vb editor to set that key combination.)![]()
Please Login or Register to view this content.
Now when you press ALT+- (ALT and minus) it will insert the AVERAGE function the same way that the autosum button works. It stops at any blank cell it encounters, just like the autosum function.
Just like the ALT+= inserts =sum(), ALT+MUA (ALT+M opens the formula ribbon, U opens the dropdown for autosum, A selects Average) inserts =average().
Don, that is a really great tip to remember :")
(however, this thread is almosr 4 years old, I doubt they are still monitoring it)
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
Thanks and you are probably quite right. Have a great weekend FDibbins.
Trying to do this in 2013...
Welcome to the Forum stinkycat!
Administrative Note:
We are happy to help, however while you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original. Also, this thread was started 13 years ago.
Please see Forum Rule #4 about hijacking and start a new thread for your query.
If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
As a new member, please take the time to review our rules. There aren't many, and they are all important.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks