0
votes

enter image description hereI have a Google spreadsheet with 7 Column. I want to lock the particular row when entry made to column F of that particular row.

I want to lock only that row not entire Google Sheet, Other rows should be free to add entry.

Check the Picture, When any value comes to Column F, Entire Particular row should be Locked for further edit and Deletion.

Any help would be obliged.

Any help. I would really obliged.

Regards Abhishek

1

1 Answers

0
votes

Something like this would fit your need. Change "Data" to the sheet you want it to happen.

function onEdit(e){
  const column = e.range.getColumn();
  const row = e.range.getRow();
  const value = e.value;
  const sheet = e.source.getActiveSheet().getSheetName();
  //Change the sheet where you want the lock
  const criteriaSheet = "Data";
  //Change your email adres
  const owner = "[email protected]";
  
  if (value != "" && column == 6 && sheet == criteriaSheet){
    SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(row, 1, 1, 6)
    .protect()
    .setDescription("Lock")
    .addEditor(owner);
  }
  
}