Reputation: 102
Is there a Google Apps Script method that will change a cell with a formula to one with a static value?
The reason for this is to avoid lag in the Sheet from lots of cell formulas recalculating as the sheet becomes larger.
I want to make the sheet replace old formulas with static values since they won't be changing.
Upvotes: 2
Views: 9336
Reputation: 31310
Use the copyValuesToRange()
method:
function copyFormulasToValues() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = ss.getSheetByName("Sheet1");
var destinationSheet = ss.getSheetByName("Sheet2");
//getRange(start row, start column, number of Rows, number of Columns)
var range = sourceSheet.getRange(1,1,1,1); //Copy content of A1
range
.copyValuesToRange(destinationSheet, 1, 1, range.getNumRows(), range.getNumColumns());
};
Upvotes: 3