2-Way Sync: No Unique ID

How to setup 2-way sync within the same workbook without any unique ID.
Important notes:
* This is the least efficient of the 3 methods, so I would suggest against it unless absolutely necessary

Sheet (Make a copy from the File menu)
https://docs.google.com/spreadsheets/d/1Pp1OvXNJjCK7nyBMS2g_Czg0-XjLXRNKVKWUlUZ4qLc

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

syncNoID(e);
}

function syncNoID(e){
const src = e.source.getActiveSheet();
const r = e.range;
if (src.getName() == “Database” || r.rowStart == 1) return;
r.clear();

let id = src.getRange(r.rowStart,1,1,5).getValues().toString();
const db = SpreadsheetApp.getActive().getSheetByName(“Database”);
let dbData = db.getDataRange().getValues();

for (let i in dbData){
if (dbData[i].toString() === id){
db.getRange(+i+1,r.columnStart).setValue(e.value);
return;
}
}
}

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

Donate on Paypal: spencer.farris@gmail.com

Leave a Reply

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