0

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 Answers 2

1

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') }); } 
Sign up to request clarification or add additional context in comments.

2 Comments

@Mogsdad do you know how to set the range so that only certain cells change color when changed?
@adcohen88 if you need this for just some cells you can list them in an array, then check the edited range with .getA1Notation() and see if that range is in the array. If you need help, just let me know (and maybe provided some cells you want to color).
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.