Created
September 7, 2017 17:15
-
-
Save jsdbroughton/c19c1d630a94a3f6b44e88f93440b92c to your computer and use it in GitHub Desktop.
Google Sheets Custom Function that returns an sum for all rows in a range or array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a sum for each row of a given array. | |
* @param {range} range The range or array to sum. | |
* @customfunction | |
*/ | |
function ROW_SUM(range) { | |
if (!range.map) { | |
range = [[range]]; // deal wih single cell ranges. | |
} | |
return range.map(function(row){ | |
return row.reduce(function(a, b) { return a + b; }, 0); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment