从Google App脚本中的按钮传递参数

时间:2019-10-11 13:52:03

标签: google-apps-script google-sheets-formula

我想笨拙地单击Google表格中的按钮,并将+1添加到特定的单元格中。

我有这个脚本:

function AddOne(inputCell) {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange(inputCell).activate();
  spreadsheet.getCurrentCell().setValue(spreadsheet.getCurrentCell().getValue() + 1);
};

在按钮上,我分配了脚本

AddOne('C6')

当我单击按钮时,出现错误Script function AddOne('C6') could not be found

您能帮我解决这个问题吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

将一个添加到当前单元格的addOne按钮

PLAY [localhost] ************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************
ok: [localhost]

TASK [Test with req_ad_user_others, containing two users tst_user2, tst_user3] **********************************************************************************************
ok: [localhost] => {
    "msg": [
        "tst_user",
        "tst_user2",
        "tst_user3"
    ]
}

TASK [Test with req_ad_user_others_emtpy, an empty string] ******************************************************************************************************************
ok: [localhost] => {
    "msg": [
        "tst_user"
    ]
}

PLAY RECAP ******************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

只需插入/绘图,选择一个加号形状。保存并将其放置在工作表上,并在脚本的右上角附加三个点。选择要增加的任何单元格,然后按加号,它将增加一个。您也可以减一。