我有一个由3列和2(或更多)行组成的范围。 中间一列包含一个公式: = TRANSPOSE(SPLIT(A1,,))
脚本需要将该范围移动(剪切)到另一个表格中,而不是公式。
google-apps-script有做PasteSpecial - Values的方法吗?
这是我目前使用的行:
sheet1.getRange(F1:H3)。moveTo(sheet2.getRange(A1));任何人都可以告诉我在移动到sheet2之前如何锁定这些值吗?
(仅供参考:这只需要一个代码解决方案) 作为替代方案,您可以使用 copyTo()进行高级参数仅复制值。为了模仿moveTo()的效果,您仍然需要清除源范围。
另外,如果更容易,getRange()接受包含工作表名称。因此: $ b $ pre $ function moveValuesOnly(){ var ss = SpreadsheetApp.getActiveSpreadsheet(); var source = ss.getRange('Sheet1!F1:H3'); source.copyTo(ss.getRange('Sheet2!A1'),{contentsOnly:true}); source.clear(); }
I have a range consisting of 3 columns and 2 (or more) rows. The middle column contains a formula: =TRANSPOSE(SPLIT(A1,","))
The script needs to move (cut) that range onto another sheet as values, not formulas.
Does google-apps-script have a means of doing "PasteSpecial - Values"?
Here is the line I'm currently using:
sheet1.getRange("F1:H3").moveTo(sheet2.getRange("A1"));Can anyone tell me how I can lock those values in before they move onto sheet2 ?
(FYI: this requires a code solution only)
解决方案Just as an alternative, you can use copyTo() with advanced arguments to copy values only. To mimic the effect of moveTo(), you would still need to clear the source range.
Also, if it's easier, getRange() accepts a string reference that includes the sheet name. So:
function moveValuesOnly() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var source = ss.getRange('Sheet1!F1:H3'); source.copyTo(ss.getRange('Sheet2!A1'), {contentsOnly: true}); source.clear(); }
更多推荐
粘贴特殊值
发布评论