简体   繁体   中英

Lock the Entire individual Row immediately for other shared user to edit after a entry made in a cell in google sheets

enter image description here I 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

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 = "yourEmail@email.com";
  
  if (value != "" && column == 6 && sheet == criteriaSheet){
    SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(row, 1, 1, 6)
    .protect()
    .setDescription("Lock")
    .addEditor(owner);
  }
  
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM