Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i execute a function when text changes in a cell? (google docs)

I've been lookin for a function to change the color of all cells in a row, when some text in a certain cell equals something. I found it here:

Google Spreadsheet: Script to Change Row Color when a cell changes text;

My question is, how can i execute this function, when the text changes?

like image 658
Kenci Avatar asked Feb 22 '12 09:02

Kenci


People also ask

How do you trigger an onEdit in Google Sheets?

The onEdit(e) trigger runs automatically when a user changes the value of any cell in a spreadsheet.


2 Answers

Search for the function onEdit. https://developers.google.com/apps-script/guide_events

like image 170
Gabriel Avatar answered Sep 24 '22 12:09

Gabriel


Given when some text in a certain cell equals something Conditional Formatting may be much simpler. onEdit would be required if the change is from 'any value' to 'any other value' (so potentially from y to x as well from x to y) but CF can be triggered in cases such as:

"from less than 100 to 100 (or to 100 or more than 100), etc.",
"from Pending to Complete (or to any member of a list such as Abandoned, Transferred, Rescheduled, etc.)",
"from more than a year left to less than a month (or a week, or 4 days, etc.)",
"from any one of Red, Orange, Yellow to Green or Blue (or either Indigo or Violet, etc.),
"from being a unique entry in a list to being a duplicate (ie without changing its own value becomes equal to any other entry)

like image 22
pnuts Avatar answered Sep 22 '22 12:09

pnuts