I'm trying to make cell A of my Google Sheet mirror the value of the most recent cell to be changed, which we will call cell B. Therefore, when some cell B's value changes, so does A. However, anytime I setValue() of A to be that of B's upon B's value being edited, A briefly contains B's value and then empties out again (the value only flashes for a second).
This is my current code:
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = e.source.getActiveSheet();
var B = e.value; // a non-specific Cell B, which has just been edited
var validation = ss.getSheetByName("Target Sheet"); // Sheet containing Cell A
range = validation.getRange("A1"); // Cell A
range.setValue(B);
}
Thanks in advance!
Figured it out! Not sure exactly what the problem was, but this seems to have worked: