2-Way Sync with Row-aligned ID

Setting up 2-way sync within the same spreadsheet where the ID and the row have a mathematical relation.
Important notes:
* This version only works when the ID and the row have a mathematical relation such that the row number can be derived from the ID number;
* This assumes the FILTER()/QUERY()/IMPORTRANGE() etc. formula is already setup and functioning properly.

Sheet (make a copy from the File menu)

function onEdit(e){
if (!e) throw “Do not run manually”;


function syncWithRow(e){
const src = e.source.getActiveSheet();
const r = e.range;
if (src.getName() == “Database” || r.rowStart == 1 || r.columnStart == 1) return;
let id = src.getRange(r.rowStart,1).getValue();
let row = id + 1;
let db = SpreadsheetApp.getActive().getSheetByName(“Database”);

Connect with me:
• spencer.farris@gmail.com
• spencerfarris.me
• www.linkedin.com/in/spencer-farris/
• Twitter @FarrisSpencer
• Google Product Expert support.google.com/docs/profile/12305

#GoogleSheets #GoogleAppsScript #appsscript

Leave a Reply

Your email address will not be published. Required fields are marked *