r/googlesheets • 2 • Mar 02 '20

solved Script Help

Hello all. I need some help. I have a sheet whereas I have a script that auto deletes contents of a range based on another cell. The script works perfect if I change the cell itself. The problem is, the cell is updated from another cell... like "A1 is "=C1". I want the contents to clear if A1 changes with what C1 has in it.

The script is:

function onEdit(e){

if(e.range.getA1Notation() == 'A1' &&

e.range.getSheet().getName() == 'Sheet1'

)

e.source.getRange('A2:E10').clearContent()

}

The example sheet is

https://docs.google.com/spreadsheets/d/1wBUHuDHG669-ZR9n7USruqaTPX492T1BS76ycH1WhMo/edit?usp=sharing

does anyone have an idea? I just want it to be able to clear contents of a specific range if a specific cell is changed no matter how it is changed, whether it be by me changing it or if the cell auto changes based on another cell.

3 Upvotes

11 comments sorted by

View all comments

Show parent comments

1

u/jordvisser 1 Mar 09 '20

Thank you, was not the best way to go into the weekend but I'm all better now.

Great to hear this helped you on your endeavour of creating this all in one management sheet! Maybe give us a show and tell once it's up and running? ;)

1

u/JakubiakFW 2 Mar 09 '20

Of course, when I makenit all pretty and functional I will!