function clearRow() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var editSheet = ss.getSheetByName("EDIT"); var lastRowEdit = editSheet.getLastRow(); for(var i = 2; i <= lastRowEdit; i++) { if(editSheet.getRange(i,1).getValue() == 'TRAIN') { editSheet.getRange('A' + i + ':C' + i).clear(); } } } function deleteRow() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var editSheet = ss.getSheetByName("EDIT"); var lastRowEdit = editSheet.getLastRow(); for(var i = 2; i <= lastRowEdit; i++) { if(editSheet.getRange(i,1).getValue() == 'TRAIN') { editSheet.deleteRow(i); } } } function insertRow() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var editSheet = ss.getSheetByName("EDIT"); var lastRowEdit = editSheet.getLastRow(); for(var i = 2; i <= lastRowEdit; i++) { if(editSheet.getRange(i,1).getValue() == 'TRAIN') { editSheet.insertRowAfter(i); } } } function replaceRow() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var editSheet = ss.getSheetByName("EDIT"); var lastRowEdit = editSheet.getLastRow(); for(var i = 2; i <= lastRowEdit; i++) { if(editSheet.getRange(i,1).getValue() == 'TRAIN') { editSheet.getRange('A' + i + ':C' + i).setValues([['AIRPLANE', 'ORANGE', 30]]); } } } https://codewithcurt.com/how-to-clear-delete-insert-and-replace-row-using-google-apps-script/
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter