[英]Google sheets: How do I concat a string in apps script?
How do I concat a value that is being copied over to another sheet?如何连接正在复制到另一个工作表的值?
Sheet 1>> Input Example (column B contains Product Name, and column C contains Color):表 1>> 输入示例(B 列包含产品名称,C 列包含颜色):
Col B |上校 B | Col C
上校 C
Shoes |鞋 | Black
黑色的
Sheet 2>> Desired Output Example:表 2>> 所需 Output 示例:
Col E (concated values) Col E(连接值)
Shoes - Black鞋子 - 黑色
function onEdit(e) {
const sh=e.range.getSheet();
if(sh.getName()=="Sheet 1" && e.range.columnStart==1 && e.value=="TRUE") {
const tsh=e.source.getSheetByName('Sheet 2');
const nr=tsh.getLastRow()+1;
//Concat Shoes with the value below
sh.getRange(e.range.rowStart,3,1,1).copyTo(tsh.getRange(nr,5,1,1));
}
}
I believe your goal as follows.我相信你的目标如下。
In order to achieve this, how about the following modification?为了实现这一点,下面的修改如何?
sh.getRange(e.range.rowStart,3,1,1).copyTo(tsh.getRange(nr,5,1,1));
const value = sh.getRange(e.range.rowStart, 2, 1, 2).getValues()[0].join(" - ");
tsh.getRange(nr, 5, 1, 1).setValue(value);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.