Home > Mobile >  Google Sheets script: delete hidden cell if another cell in same row is deleted
Google Sheets script: delete hidden cell if another cell in same row is deleted

Time:05-25

I'm pretty sure this is easy. I want a cell in a hidden column to be deleted automatically (OnEdit) if another cell in the same row is deleted. In the case of the picture below, if I delete text in B13, I want the content in the (hidden) E13 to also be deleted. Or if I delete B18, I want E18 to be deleted. The thing is if the hidden E Column is not deleted the Columns H and I will be effected. I also want this script to work in any sheet/tab (all tabs have the same format).

enter image description here

enter image description here

References:

CodePudding user response:

Try it this way

function onEdit(e){
  const sh = e.range.getSheet();
  if(e.range.rowStart > 7 && e.range.columnStart == 2 && e.oldValue && !e.value){
    sh.getRange(e.range.rowStart, 5, e.range.rowEnd - e.range.rowStart   1).clearContents();
  }
}

Yes deleeting two rows and one time is a problem which requires a more complex solution.

  • Related