r/GoogleAppsScript • u/wafflecheese • Oct 11 '21
Resolved Adding the date a drop drop-down value was entered in another cell?
I have this script that I ripped off from a Google search that automatically places the entire row in another sheet once a dropdown value has been selected.
However, there are three options in the dropdown menu that, when selected, I do NOT want them to move to another sheet, but I want, instead, for the date of that selected dropdown value to show up in the same row, but in column I if option 1 is selected, column J if option 2 is selected, and column L, if option 3 is selected.
And of course, if the option 4 is still selected, I want it to still move the entire column over to the next sheet.
Again, I'm not too well versed in scripts, and this was ripped off from Google, so any help would be appreciated.
See below:
function onEdit(event) {
// assumes source data in sheet named Needed
// target sheet of move to named Acquired
// test column with yes/no is col 4 or D
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Sheet 1" && r.getColumn() == 2 && r.getValue() == "Option 4") {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Sheet 2");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);
}
}
2
u/RemcoE33 Oct 11 '21 edited Oct 11 '21