Google-sheets – Hide row if cell contains specific text

google sheets

I am trying to hide a row when a cell is filled with "x". I have tried using scripts but they don't work.

So there are "A", "B" and "C" filled in column F.

I want the script to hide rows where "A" and "B" are filled in column F.

So if row 3 and 4 contain "A" in column F, those should be hidden.

Best Answer

function onEdit(f) {
  if (f.range.getColumn() == 6 && f.value == "A" || f.value == "B") {
    f.range.getSheet().hideRows(f.range.getRow());
  }
}