问题
I need to create a custom function in Google Apps Script that will allow me to input the location of certain cells and then the function would output into new cells. This is what I tried sofar:
function SetRange(RowNum) {
var app = SpreadsheetApp;
var ss = app.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
sheet.getActiveCell(),setValue(45)
sheet.getRange(RowNum,24),setValue(51);
}
I get the error that "SetValue is not defined. I am building this program as I learn so there are some facts that veteran programmers would know that I do not. Thanks again for all your help
回答1:
Custom functions could return an array of values but can't use setValue() or setValues().
Example
function demo(){
var output = [
[1,2],
[3,4]
]
return output;
}
If we add =demo()
to A1, the result will be:
| A | B |
--+-----+-----+
1| 1| 2|
2| 3| 4|
来源:https://stackoverflow.com/questions/48464414/how-to-create-a-custom-function-that-returns-data-to-multiple-cells