I need some "live" cell data (values only), which get their data from another sheet; an arrayformula is not sufficient.
I'm thinking something that copies column A:13
-down from Sheet1 (whenever it changes), and then pastes the values, beginning at row 3 of column A on Sheet2.
This answer looks like a starting point for me but lacks any mention of doing it automatically when the contents change.
Can anyone help me out?
EDIT: Thanks @Tom, my implementation of the script looks like this:
/**
* A function named onEdit will be called whenever
* a change is made to the spreadsheet.
*
* @param {object} e The edit event (not used in this case)
*/
function onEdit(e){
var copyFromRange = 'ReportCalculations!A1:E39';
var copyToRangeStart = 'Report!A1';
copyValuesOnly((copyFromRange, copyToRangeStart));
}
/**
* This function will copy the values from a given range to
* a second range, which starts from the given cell reference
*
* @param {string} copyFromRange Range reference eg:
* @param {string} copyToRangeStart Cell reference eg:
*/
function copyValuesOnly(copyFromRange, copyToRangeStart) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getRange(copyFromRange);
source.copyTo(ss.getRange(copyToRangeStart), {contentsOnly: true});
}
At this point when the ReportCalculations
sheet is edited, I'm still left with an empty Report sheet – must be missing something
My steps so far:
- Created the new script and saved it
- Tried editing the sheet (nothing)
- Then tried manually running the script from the script manager, which asked me for authorization (which I gave), then tried editing the
ReportCalculations
sheet again and still nothing in the Report sheet.