You are here:


Library name IPSubnetCalculator
Difficulty Low (basic JavaScript knowledge required)
Returned value Array of objects
Description JavaScript module for calculating optimized subnet masks for standard and non-standard IP ranges, e.g. –
Link https://github.com/franksrevenge/IPSubnetCalculator
License MIT
Library implementation
  • Go to ‘Tools’ menu, select ‘Add library’ (read more how to add library here)
  • Give a name to the library (IPSubnetCalculator), add required file:

Url 1: //franksrevenge.github.io/IPSubnetCalculator/lib/ip-subnet-calculator.js

  • Add description (optional). 
  • Click ‘OK’.
Custom functions

There are three helper functions to get the results from the library (read more how to add a custom function here):


These functions are only our proposals to deal with the library, but user can define their own function(s).

The description of all of these functions is below:

Function name IPSUBNET
Arguments – ipStart
– ipEnd
Syntax =IPSUBNET(ipStart, ipEnd)

Main connector. Calls the library function and returns the result as an array with the mask objects. Each mask object consists of the properties:

ipLow, ipLowStr, ipHigh, ipHighStr, prefixMask, prefixMaskStr, prefixSize, invertedMask, invertedMaskStr, invertedSize

Detailed description of the properties can be found here: https://github.com/franksrevenge/IPSubnetCalculator

Function body
var ipsubnet = IpSubnetCalculator.calculate(ipStart, ipEnd);
return ipsubnet;
Example =IPSUBNET('','') or =IPSUBNET(A6,B6)


Function name OBJECTCOUNT
Arguments When defining the function leave ‘Arguments’ empty. This will allow to accept any number of arguments passed to the function (in this case array of objects).
Syntax =OBJECTCOUNT(ipSubnetObject)

Counts number of returned IP mask objects

Function body
return arguments.length; //'arguments' is an array passed to the function


Function name OBJECTVALUE
Arguments – index
– property
– obj
Syntax =OBJECTVALUE(index, property, obj)

Returns specified (by index) property of IP mask

Function body
var row = obj[index];
var value = row[property];
return value;
Example =OBJECTVALUE(0,'ipLowStr',IPSUBNET(A$6,B$6))

Ready spreadsheet is presented below:

Get the copy of this spreadsheet