I am trying to get the onEdit() simple trigger to do an action on all edited cells in Google Sheets. The problem is that if you edit a collection of non adjacent cells, the event object only picks up the first range selected.
For example, I have the following code. If I enter a formula or value a cell in my sheet, the script automatically changes the background color to red.
function onEdit(e) {
var range = e.range;
range.setBackgroundRGB(255, 0, 0); //set color to red
}
The problem arises if I select many ranges (or cells) with the mouse that are not adjacent to each other and change all their values at once (for example if I copy a value from somewhere, and paste it into many adjacent cells at once). Instead of the script changing all of their background colors, it only changes the color of the first range selected.
Thanks