AutoHotkey and Excel Worksheet functions: Mean/Average, Median & Mode

Excel worksheet functionsTypically I like to use AutoHotkey to insert the formula into Excel.  This allows for the user to make changes (or have it update if the  data changes).   Sometimes I just want a given value based on the data at-hand.  This is when it is awesome to be able to call the Excel worksheet functions.  In the below code and video I demonstrate how to call three Summary variables of central tendency: Mean (Average), Median and Mode.   For normally distributed data these will be the same however, in the real world, data is often skewed / non-bell shaped (has kurtosis).  Make sure you review the data to decide which best “summarizes” the data.

In the video I show how I initially planned to create three separate functions (one each summary variable) however with some help from Maestrith (author of AHK Studio) I was able to write one function and pass the method as a parameter.  🙂

Here is the script for Excel worksheet functions

And here is the video where I walk through Excel worksheet functions

Excel & AutoHotkey-Worksheet functions: Mead, Median & Mode

I can’t tell you the # of times AutoHotkey Variadic Functions come in handy

AutoHotkey Variadic FunctionsAutoHotkey Variadic Functions can be incredibly handy when you don’t know the exact number of parameters.   The below example shows some simple math where you can pass any number of parameters to be added.  It also demonstrates how you can use MaxIndex() to determine how many parameters were passed to the function.

Demonstration using AutoHotkey Variadic Functions

How to create and use variadic functions in AutoHotkey

Tips & Tricks for using functions in AutoHotkey

functions in AutoHotkeyFunctions in AutoHotkey are a great tool to have in your bag!  They can definitely help simplify your code, ease re-purposing of code and avoid a lot of simple mistakes by keeping the variables local (instead of global).  AHK Studio is an editor written in and for AutoHotkey.  It helps both noobs & gurus write great code and is worth a deep look!

The below video reviews a few tips & tricks for working with functions.

Functions in AutoHotkey

AutoHotkey funcitons: tips and tricks