I have a function that has a name with a set of data and this name is compared to a list of names. If that name is already in the list of names, the data associated with the name replaces the old data. If the name is a name not in the list of names it adds the name and the associated info to the bottom of the list.
For some reason when I run the code with a name already in the list, the original data is replaced and the name and data are added to the bottom of the list. I want to avoid repeating people while also adding new individuals.
var app = SpreadsheetApp;
var activeSheet = app.getActiveSpreadsheet();
var lookup = app.getActiveSpreadsheet().getSheetByName("Lookup");
var issued = app.getActiveSpreadsheet().getSheetByName("Issued");
var name1 = lookup.getRange(12,3).getValue();
var info = lookup.getRange(16,3,1,12).getValues();
for (var j=1;j<105;j++){
var issuedOfficers = issued.getRange(j,11).getValue();
//if the officers name is already recorded in issued the system will replace the current data with updated data
if (issuedOfficers === name1){
issued.getRange(j,1,1,12).setValues(info);
} else {
var lastrow = issued.getLastRow();
issued.getRange(lastrow+1,1,1,12).setValues(info);
break;
}
}
}```
Aucun commentaire:
Enregistrer un commentaire