Reputation: 361
I cannot get this code to do what I am trying to get it to do. If there is a TRUE in Column 10 then run the Sort Query on SendToTotalSales - NOT ONLINERELOCATION
function MoveDonations(e) {
var sh=e.range.getSheet();
if(sh.getName()!='ONLINERELOCATION')return
if(e.range.columnStart==10 && e.value=="TRUE") {
e.source.getActiveSheet().getRange(row,????).setFormula('=SORT(QUERY(ONLINERELOCATION!A2:J,"SELECT A,
F, G, D",0))');
}
//var tsh=e.source.getSheetByName("SendToTotalSales");
//var trg=tsh.getRange(tsh.getLastRow()+1,1);
//sh.getRange(e.range.rowStart,1,1,4).copyTo(trg);
}
I am hoping I was Close !
Thanks in Advance
Upvotes: 1
Views: 84
Reputation: 201553
ONLINERELOCATION
is checked, you want to copy the values of the columns "A,D,F,G" to the sheet of SendToTotalSales
as "A,F,G,D".If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.
In this case, you can also use the simple OnEdit event trigger (onEdit(e)
).
function MoveDonations(e) {
var range = e.range;
var sheet = range.getSheet();
if (sheet.getSheetName() == "ONLINERELOCATION" && range.columnStart == 10 && range.columnEnd == 10 && range.rowStart >= 2 && e.value == "TRUE") {
var [[a,,,d,,f,g]] = sheet.getRange(range.rowStart, 1, 1, 7).getValues();
e.source.getSheetByName("SendToTotalSales").appendRow([a, f, g, d]);
}
}
ONLINERELOCATION
. By this, the values of the row are copied to SendToTotalSales
.'=SORT(QUERY(ONLINERELOCATION!A2:J,"SELECT A, F, G, D",0))'
is used, all values are put. So I proposed above script.Upvotes: 2