粘贴特殊值 [英] Paste Special Values

查看:68
本文介绍了粘贴特殊值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由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();
}

这篇关于粘贴特殊值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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