将单元格的值复制到另一个单元格

时间:2014-04-03 10:21:58

标签: google-apps-script

代码:

function CopyPasteA6() {
   var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');            
   var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');            
   sheet1.getRange('A6').copyTo(sheet2.getRange('A6'))
}

这将复制整个单元格,包括公式。如果我只是想复制单元格值,如果有任何公式则遗漏,那可能吗?

1 个答案:

答案 0 :(得分:1)

function CopyPasteA6() {
   var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');            
   var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');            
   sheet2.getRange('A6').setValue(sheet1.getRange('A6').getValue());
}