Reputation: 1
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
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();
}
}
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
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