Reputation: 135
I have a sheet which one column (column 10) is a drop down list with 2 possibilities : official or non official. I'm trying to create a script that export this sheet to another with this condition : Each row with "Official" in the column 10 have to be duplicated as "non official" (so in this case we will have 2 rows one official and one non official)
So this is my code :
const tab = active_sheet.getRange("A2:M14").getValues();
for (let nbline=0; nbline <tab.length;nbline++) {
if (tab[nbline][10] == "official") {
And I don't find the command to duplicate this line, keep all information and just change the column 10 to "non official"
If someone can help me
Thanks
Upvotes: 2
Views: 1479
Reputation: 610
So you want to keep the line with "official" and add another one that has the same values except it is "non official", right?
Try something like this:
const tab = active_sheet.getRange("A2:M14").getValues();
var result = [];
for (let nbline=0; nbline <tab.length;nbline++) {
result.push(tab[nbline]);
if (tab[nbline][10] == "official") {
tab[nbline][10] = "non official";
result.push(tab[nbline]);
}
}
Upvotes: 2