【问题标题】:Triggering a script on a google sheet after editing a separate sheet编辑单独的工作表后在谷歌工作表上触发脚本
【发布时间】:2017-12-07 22:59:56
【问题描述】:

你好,我正在使用谷歌表格为 D&D 制作一个倡议表。 目前我有一个我自己(DM)可以在其中编辑和更改的 Mainsheet,还有一个 Playersheet,其中包含玩家使用 IMPORTRANGE 所需的数据。

我正在尝试编写一个脚本,该脚本将自动隐藏 PlayerSheet 中所有空的“主动”单元格。 我已经成功地编写了这个脚本,但是我希望它在我编辑 MainSheet 的任何时候触发。 因为工作表中的所有日期都来自使用 IMPORTRANGE,所以我无法使用 on edit 触发器,因为 PlayerSheet 永远不会被编辑。

是否可以让位于 PlayerSheet 中的脚本在我编辑 MainSheet 时运行? 最重要的是,是否可以仅在我编辑 F 列中的数据时才运行脚本?

【问题讨论】:

    标签: google-sheets


    【解决方案1】:

    要在编辑电子表格时运行脚本,您可以在编辑时创建一个函数。

    function onEdit(e){
        var range = e.range;
        //here you can check if the column if F or not and run your code.
    }
    

    Tu change the values of another spreadsheet, when selecting the spreadsheet you want to do the actions on, instead of selecting the active one, you can edit one with the url.类似的东西:

    var doc = SpreadsheetApp.openByUrl("paste the url here");
    var sheet = doc.getSheetByName("Name of the sheet");
    etc...
    

    然后在玩家电子表格上进行您需要做的修改。

    【讨论】:

    • 非常感谢,这正是我需要的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 1970-01-01
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 2022-10-18
    • 1970-01-01
    相关资源
    最近更新 更多