The tool I'm working on displays a list of Google Drive files. Users are prompted to put an "X" next to every file they want to have included in a Master Library of document links. After the files are added I delete every row that has an "X".
While testing today I noticed that if I type "X" in a cell but do NOT hit ENTER before clicking the "Add Selected Files to Library" button, that file doesn't get added. That's fine, the problem is that there is still a selected cell with an "X" in it, but it's off by one.
Is there a way to clear the cell being edited? Or move the cell being edited to account for the deleted row?
If it helps, here's my code (I'm obviously not a professional coder, so thanks for your patience):
function addToLibrary() {
var x = 2;
var added = 0;
var dupes = 0;
lib_last = libSheet.getLastRow();
while (sheet.getRange(x,1).getValue() != "") {
if (sheet.getRange(x,5).getValue() != "") {
id = sheet.getRange(x,1).getValue();
var checkRow = checkDupes(id);
if (checkRow >= lib_last + 1) {
var my_name = DriveApp.getFileById(id).getName();
SpreadsheetApp.getActiveSpreadsheet().toast('The design file: ' + '"' + my_name + '"' + ' has been added to the Library!', "ADDED FILE...",600);
var my_link = DriveApp.getFileById(id).getUrl();
getDeets(id, my_link);
lib_last++;
added++;
}
else {
dupes++;
}
}
x++;
}
SpreadsheetApp.getActiveSpreadsheet().toast("", "",0.1);
Browser.msgBox("Finished! Documents added: " + added + ". Duplicate documents: " + dupes);
for (var i = x - 1; i>=2; i--) { // Deletes rows with non-null
if (!sheet.getRange(i,5).isBlank()) {
sheet.deleteRow(i);
}
}
}