I've found this script that does everything what I want, besides deleting the actual name. I have a sheet where I enter a name in cell G2 on sheet "-Dossier", after that I want to find this name in the "ZZZ - Medewerkers" sheet and when the script finds the name in that sheet I want to delete the name from that sheet. The name on the "ZZZ - Medewerkers" sheet is always in Column A.
The script that I am using now is able to find the row where the name is specified, but I have not figured out on how to actually delete the name from the sheet. Could anyone help me out?
function rowOfEmployee(){
var ss = SpreadsheetApp.getActive();
var sh2 = ss.getSheetByName('ZZZ - Medewerkers');
var sh1 = ss.getSheetByName("-Dossier");
var data = sh2.getDataRange().getValues();
var employeeName = sh1.getRange("G2").getValue();
for(var i = 0; i<data.length;i ){
if(data[i][0] == employeeName){ //[0] because column A
Logger.log((i 1))
return i 1;
CodePudding user response:
Try it this way
function rowOfEmployee(){
var ss = SpreadsheetApp.getActive();
var sh1 = ss.getSheetByName("-Dossier");
var employeeName = sh1.getRange("G2").getValue();
var sh2 = ss.getSheetByName('ZZZ - Medewerkers');
sh2.createTextFinder(employeeName).matchEntireCell(true).replaceAllWith('');
}