Google Sheets – Add a formula to the drop down button that automatically copies data to another sheet

huangapple go评论63阅读模式
英文:

Google Sheets - Add a formula to the drop down button that automatically copies data to another sheet

问题

I am looking for a script that I could input under the drop down button in a Google sheet.
我正在寻找一个可以在Google表格的下拉按钮下输入的脚本。

The drop down has three options "not submitted", "in progress", and "submitted".
下拉框有三个选项:“未提交”,“进行中”和“已提交”。

Most of the data on here makes use of a drawer button or form.
这里的大多数数据都使用抽屉按钮或表单。

I just want to be able to copy the data of a row automatically to another sheet when I toggle the submitted in the drop down button in that row.
我只想在切换行中的下拉按钮中的“已提交”时,能够自动将行的数据复制到另一个表格。

Do you have any suggestions?
你有什么建议?

Edit
编辑

Basically from this sheet 1 to sheet 2 when submitted is toggled.
基本上,当提交被切换时,从表1到表2。

Google Sheets – Add a formula to the drop down button that automatically copies data to another sheet

to

Google Sheets – Add a formula to the drop down button that automatically copies data to another sheet

英文:

I am looking for a script that I could input under the drop down button in a Google sheet.
The drop down has three options "not submitted", "in progress", and "submitted".

Most of the data on here makes use of a drawer button or form.

I just want to be able to copy the data of a row automatically to another sheet when I toggle the submitted in the drop down button in that row.

Google Sheets – Add a formula to the drop down button that automatically copies data to another sheet

Do you have any suggestions?


Edit
Basically from this sheet 1 to sheet 2 when submitted is toggled.

Google Sheets – Add a formula to the drop down button that automatically copies data to another sheet

to

Google Sheets – Add a formula to the drop down button that automatically copies data to another sheet

答案1

得分: 0

我认为你不需要一个脚本。 你可以使用以下公式来实现你想要的结果:

=IF(Sheet1!D3="已提交",INDEX(Sheet1!A3:C3),Sheet1!D3)

将这个公式放在第一个单元格中,然后拖动以填充其他单元格。

如果你只想要在"已提交"时获取数据(而不是在"进行中"或"未提交"时),使用以下公式:

=IF(Sheet1!D3="已提交",INDEX(Sheet1!A3:C3),"")

(请根据你的范围和语言环境来调整公式)

英文:

I don't think you need a script for that.
You can achieve your desired result using a formula

=IF(Sheet1!D3="submitted",INDEX(Sheet1!A3:C3),Sheet1!D3)

Put this formula in the first cell and drag it down.

If you only want the data when "submitted" (and not the "in progress" or "not submitted"), use this formula.

=IF(Sheet1!D3="submitted",INDEX(Sheet1!A3:C3),"")

(Do adjust the formula according to your ranges and locale)

Google Sheets – Add a formula to the drop down button that automatically copies data to another sheet

答案2

得分: 0

这可以通过常规公式来完成,在电子表格2中,您可以设置一个类似于这样的公式=QUERY(IMPORTRANGE("链接到表格1的链接","A:D"),"Select * WHERE (Col4='已提交')")。这样,它将仅从电子表格1的范围中拉取数据,其中您的范围中的第4列的值设置为"已提交"。

但如果您想使用Apps脚本,您可以使用OnEdit触发器,以便它在每次更新时检查,并使用values.Batchget方法获取表格1上范围的值,然后在脚本中检查范围中位置4的值是否等于"已提交",然后使用values.update方法在电子表格2上进行更新。

但我建议使用公式,因为它更容易,并且不需要任何编程。

英文:

This can be done with regular formulas, in spreadsheet 2 you can set a formula like this =QUERY(IMPORTRANGE("{Link of sheet 1}","A:D"),"Select * WHERE (Col4='Submitted')")

That way it will pull the data from the range of spreadsheet 1 only where the value of the column 4 in your range is set to "Submitted".

But if you want to use Apps script you can use the OnEdit trigger so that it checks on every update and use the values.Batchget method to get the values of the range on sheet 1, then check in the script if the value of the position of 4 in the range is equal to "Submitted" then use the method values.update on spreadsheet 2

But I would suggest using the formulas as its way easier and doesn't require any programming

huangapple
  • 本文由 发表于 2023年5月15日 10:12:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76250482.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定