粘贴特殊值

编程入门 行业动态 更新时间:2024-10-24 15:16:39
本文介绍了粘贴特殊值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

粘贴特殊值

本文发布于:2023-10-14 12:03:08,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!