Aaron
Aaron

Reputation: 3325

Copy value of cell to another cell

The code:

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

This will copy the entire cell, including the formula. If I just want to copy the cell value and leave out if there is any formula, is that possible?

Upvotes: 0

Views: 2404

Answers (1)

Serge insas
Serge insas

Reputation: 46794

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

Upvotes: 1

Related Questions