Gomaa A Mahmoud
Gomaa A Mahmoud

Reputation: 1

How to lock or protect row after data entry or input in google sheet

How to lock or protect a row after data entry or input in Google sheet. Column F is a "Timestamp" and it is a blank all time. I need to protect the Row when F not a blank.

Upvotes: 0

Views: 1160

Answers (2)

Cooper
Cooper

Reputation: 64140

Protecting a row in which column F is not Blank

function onEdit() {
  var sh=e.range.getSheet();
  if(sh.getName()!='TheNameOfTheSheetYouWantThisToWorkIn')return;//change to whatever sheet your using
  if(e.range.columnStart==6 && !e.range.isBlank()) {
    sh.getRange(e.range.rowStart,1,1,sh.getLastColumn()).protect();
  }
}

Read about simple triggers

Learn more about onEdit event object

Requested Integration:

function onEdit(e)
{
  var sh = e.range.getSheet();
  if(sh.getName()=='Activity Log' && e.range.columnStart==2 && e.range.rowStart>1) {
     applyFirstLevelValidation(e.value,e.range.rowStart);
  }
  if(sh.getName()=='Activity Log' && e.range.columnStart==3 && e.range.rowStart>1) {
    applySecondLevelValidation(e.value,e.range.rowStart);
  }
  if(sh.getName()=="SheetName" && e.range.columnStart==6 && !e.range.isBlank()) { //you need to modify the SheetName
    sh.getRange(e.range.rowStart,1,1,sh.getLastColumn()).protect(); 
  } 

}

Upvotes: 1

Gomaa A Mahmoud
Gomaa A Mahmoud

Reputation: 1

**Thanks for your reply :) but i have many onEdit function in my cod and this make a conflict please check the below **

https://docs.google.com/document/d/1wcUUU0GdotuCny1jJ_aGuQU4H4vtMlC8ixYSMOkuMGA/edit?usp=sharing

Upvotes: 0

Related Questions