I'm working in Google sheets trying to set up two onEdit scripts, one to work right after the other. I'm not really a coder but can at least somewhat read coding and for the most part, figured out what and where to change things to make scripts work for my spreadsheet. I've looked all over StackOverflow and Google's help forum but nothing exactly has helped with me with the issue I'm facing.
Here is what I'm trying to do. Column 12 (L) is a status column with the options; In progress, No Resolution, Resolved.
When anything gets flipped to Resolved, I'd like it to move to the bottom of the spreadsheet and then that bottom row gets highlighted.
Here are the two scripts I'm working with, on their own they do what I want but together the second script runs first highlighting the row, and then it moves to the bottom. Also for some reason when the second script is active there is a 50-50 that when the entry is moved to the bottom is moves up one row.
First script:
function onEdit(e){
// assumes source data in sheet named Problems
// target sheet of move to named Problems, Problems
// test column with yes/no is col 12 or L
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Problems" && r.getColumn() == 12 && r.getValue() ==
"Resolved") {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Problems");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);
}
}
Second script:
function onEdit2(e) {
if (e) {
var ss = e.source.getActiveSheet();
var r = e.source.getActiveRange();
if (r.getRow() != 1 && ss.getName() == "Problems") {
status = ss.getRange(r.getRow(), 12).getValue();
rowRange = ss.getRange(r.getRow(),1,1, 12);
if (status == 'Resolved') {
rowRange.setBackgroundColor("#99ccff");
}
}else if (status == '') {
rowRange.setFontColor("#000000");
}
}
}
I've set the onEdit2 to a trigger but that hasn't worked :(
Any help is appreciated and please let me know if any more information is needed.