无需手动编辑的OnEdit功能 [英] OnEdit Function without Manual EDIT

查看:76
本文介绍了无需手动编辑的OnEdit功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当特定列中发生更改时,我都会使用OnEdit函数将数据移动到另一张工作表.但是,更改应该通过公式进行.但是,它不起作用.

I use an OnEdit function to move data to another sheet whenever a changed in a particular column. But The change should happen with a formula. But, it is not working.

示例:当我手动将A1更改为"ok"时,OnEdit函数起作用,但是当A1单元格通过If条件更改为"ok"时,它没有移动,也没有移动.

example : When I change A1 to "ok" manually the OnEdit function work, but when the A1 cell change through an If condition to "ok" it's not moving and there is no movement.

您能在没有人为干预的情况下帮助我执行Onedit功能吗?

Can you help me work the Onedit function without a human interfere?

推荐答案

问题:

您可以在官方文档中看到 :

onEdit(e)用户更改电子表格中的值时运行.

onEdit(e) runs when a user changes a value in a spreadsheet.

今天,此触发器不会跟踪通过编程方式进行的更改:

That is to day, this trigger does not track changes that are made programmatically:

脚本执行和API请求不会导致触发器运行.例如,调用 Range.setValue()编辑单元格不会导致电子表格的onEdit触发器运行.

Script executions and API requests do not cause triggers to run. For example, calling Range.setValue() to edit a cell does not cause the spreadsheet's onEdit trigger to run.

解决方法:

对此限制的一种可能的解决方法是使时间驱动触发器.例如,您可能有一个触发器,该触发器将触发每分钟,而无需考虑电子表格是否已被编辑.

Workaround:

A possible workaround to this limitation is to have a time-driven trigger instead. You could, for example, have a trigger that will fire every minute, disregarding whether the spreadsheet was edited or not.

然后,在触发的函数内,您可以想到一种检查电子表格是否在最后一分钟内被编辑的方法(例如,将先前的值存储在另一张工作表或

Then, inside the triggered function you could think of a way to check if the spreadsheet was edited during the last minute (for example, have the previous values stored in another sheet, or in a script property, and compare them to the current ones), and execute your desired actions if that's the case.

这篇关于无需手动编辑的OnEdit功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆