Please note javascript is required for full website functionality.


Custom Functions in Excel using Developer Preview and JavaScript

18 December 2017

Excel 2016 now supports custom functions in JavaScript, albeit in Developer Preview.

Custom functions, similar to user-defined functions (UDFs) are JavaScript functions that you can build as part of an add-in. Users can see and run those functions in Excel alongside built-in functions like =SUMPRODUCT or =OFFSET. Whilst the Developer Preview is only available on Windows for now, all is not lost – once created, these functions will work everywhere add-ins do: on your PC, Mac, and iPad and even in Excel Online. Take that, VBA!

Microsoft offers a simple example to add 42 to two numbers:

function add42(num1, num2) {

return num1 + num2 + 42;


A more complex version is shown in our image!

JavaScript does appear to be out to usurp VBA. Examples can be found online to demonstrate its prowess such as:

  • Calculate mathematical operations, e.g. whether a number is prime or co-prime
  • Fetch information from the web, like a bank account balance
  • Stream live data, like a stock price.

You can find various examples here.