0
votes

I have a populated Google Spreadsheet with multiple editors and need to track changes made to it. The easiest way I thought to do this was to have cells automatically change their background color to red when adjusted by a user.

i.e. if a user changes the text in cell B3 from "Peter" to "Parker", B3's background color would automatically change to red.

Is this something that should be done in script editor? If so, I would imagine the function onEdit (e) would be applicable?

Any guidance is greatly appreciated.

-Adam

2

2 Answers

1
votes

This code would do that:

function onEdit(e) {
   e.range.setBackground('red')
}

In case you need to reset to white background every now and then

function resetBG() {
    SpreadsheetApp.getActive().getSheets()
    .map( function (s) {
        s.getDataRange().setBackground('white')
    });
}
1
votes

If you want the range to be highlighted when others edit it try this:

function onEdit(e){
  var email = Session.getActiveUser().getEmail();
  if (email !== "Type your email here") {
    e.range.setBackground('red')
  }
}

Type in your email address, so your edit's don't get highlighted.