0

so I found a great answer to a question that I had about connecting two different spreadsheets with a link that would allow you to edit either one and the other would update, I found a great page on this but I'm not quite sure how to implement it.

var targetID = 'spreadsheet-id';
var targetSheetName = 'Sheet1';

function onEdit(e) {
  // Get the event object properties
  var range = e.range;
  var value = e.value;
  //Get the cell position 
  var row = range.getRowIndex();
  var column = range.getColumnIndex();
  exportValue(row,column,value)
}

function exportValue(row,column,value) {
  var ss = SpreadsheetApp.openById(targetID);
  var s = ss.getSheetByName(targetSheetName); 
  var target = s.getRange(row, column);
  target.setValue(value);
}

So to give you a bit of insight into what I see here: I understand the first two lines are placeholders for later on, the onEdit function has a variable e(I'm not quite sure on what that does but ill go with it for now). then in the next two lines you set the range and value of the box that's going to be updated and I don't know what to change range and value to, to get this to work.

Then the row is the row it is in, column is the column it is in and then the function uses the exportValue function to paste the data to the other spreadsheet.

So this bits that I don't understand are the lines 6 and 7 range and value parts, the need for e and i guess how this works continuously.

The aim is to have a master spreadsheet and then lots of little spreadsheets that are basically just a single sheet from the master so that specific people can only see specific pages of the master spreadsheet.

Thanks in advance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.