When the value in P47 changes, I'd like a range of cells to copy from column L to column A of that same sheet. (I don't think I'm succesfully entering the "IF" condition but I'm not sure how to test that.)
function onChange(e) {
const range = e.range;
const activeSheet = e.source.getActiveSheet().getName();
const conditions = [
activeSheet === 'MATCHUPS',
range.getRow() == 47,
range.getColumn() == 16
]
if (conditions.every(c => c === true)) {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('L49').activate();
spreadsheet.getRange('A49:A74').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
}
}
The onChange event is for structural changes.
From what you describe, you're looking for the OnEdit event, which is for when the user makes manual changes to cell contents.
Here's the code I think you might want:
function onEdit(e) {
var sht = e.range.getSheet();
var cell = e.range.getA1Notation();
var src = sht.getRange("A49:A74");
var dst = sht.getRange("L49:L74");
if (sht.getName() === "MATCHUPS" && cell === "P47") {
src.copyTo(dst);
}
}