I'm trying to create a custom function in my google spreadsheet with the script editor.
I can't seem to allow the user to give the function an array as the argument.
My script works when I hardcode like this:
var values = SpreadsheetApp.getActiveSheet().getRange("G2:j30").getValues();
What I want to do is pass the array as an argument:
function arrayToList(chosenArray) {
...
var values = SpreadsheetApp.getActiveSheet().getRange(chosenArray).getValues();
...
}
There are two ways to pass an array as argument to a Google Sheets custom function
A1:D5. Usage: =myCustomFunction(A1:D5).{1,2;"Yellow","Orange"}. Usage: =myCustomFunction({1,2;"Yellow","Orange"}).
Note: If your spreadsheet is set to use comma as decimal separator use / as column separatorReferences
Now this functionality is not implemented in GAS. There are similar questions in SO (here and here). You can post a feature request to the issue tracker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With