Google电子表格脚本将两个单元格添加在一起 [英] Google spreadsheet script to add two cells together
本文介绍了Google电子表格脚本将两个单元格添加在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两列有数字的列。我需要一个我可以通过菜单调用的脚本来添加这两列,然后清除第一个值。我一直无法找到如何做到这一点的任何示例,所以我没有任何尝试的代码。
示例:
D12 E12
10 26
我想要一个脚本,将E12改为36,然后清除单元格D12。 解决方案
您需要使用getRange ) http://goo.gl/vDqrA
我认为这应该做到这一点。
var ss = SpreadsheetApp.getActiveSheet();
var num1 = ss.getRange(D12)。getValue();
var num2 = ss.getRange(E12)。getValue();
ss.getRange(E12)。setValue(num1 + num2);
ss.getRange(D12)。clear();
I have two columns with numbers in them. I need a script I can call via menu to add these two columns, and then clear the value in the first. I have been unable to locate any examples on how to do this, so I don't have any attempted code.
Example:
D12 E12
10 26
I would like a script that would change E12 to 36, then clear cell D12.
解决方案
You need to use getRange() http://goo.gl/vDqrA
I think this should do it.
var ss = SpreadsheetApp.getActiveSheet();
var num1 = ss.getRange("D12").getValue();
var num2 = ss.getRange("E12").getValue();
ss.getRange("E12").setValue(num1+num2);
ss.getRange("D12").clear();
这篇关于Google电子表格脚本将两个单元格添加在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文