[英]How to copy values from one sheet and paste them into another using Google Sheets Macros?
[英]How to copy value from one column to another on Google Sheets?
是否有任何公式或脚本可以仅将值(而不是公式)从一列复制到另一列? 我不想使用 CTRL + SHIFT + V 因为我需要它是自动的。 例如:
Column A Column B
Value1
Value2
Value3
A列的所有值都是用数组公式计算的,我需要每次A列有新记录时,值永远传递到B列,所以如果A列中的值或公式被删除,复制的值保留在列中B、可以这样做吗?
请任何帮助!
你想要
如果我的理解是正确的,这个答案怎么样? 请将此视为解决问题的多种可能方法之一。
流动:
1. 获取活动工作表 2. 获取活动范围(列) 3. 将值粘贴到范围(列)中
示例脚本:
function copyvalues() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Sheet1');
const rg = sh.getRange(1,1,sh.getLastRow()); //Explore the various getRange functions
const va = rg.getValues(); //Explore Arrays if you are not familiar with it
va.forEach(function(r,i){
sh.getRange(i+1,2).setValues(r[0]).setNumberFormat('#,##0.00'); //Use setNumberFormat if you need to format your values with two decimal places and thousands separator (if not already done so)
})
}
参考:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.