Search code examples
google-apps-scriptgoogle-sheetsdropdown

Delete a cell in google sheets after changing a dropdown value


i have 2 columns with dropdown lists in google sheets. All cells in A3:A26 has the first dropdown list. I would like that the cell in the Column B gets deleted, if i change the dropdown in Column A. For example Dropdown in A3 gets changed, Value in B3 gets deleted. Dropdown in A12 gets changed, Value in B12 gets deleted.

I have no clue how to do it.


Solution

  • Try

    function onEdit(event) {
      var sh = event.source.getActiveSheet();
      var rng = event.source.getActiveRange();
      if (sh.getName() == 'mySheet' && rng.getColumn() == 1 && rng.getRow() > 2) {
        rng.offset(0,1).clearContent()
      }
    }