我找到了基本解决方案https://stackoverflow.com/a/4809413/1438650,但它缺乏我项目的条件和非连续方面。我需要该副本基于 Col G 的值,然后将 A、B 和 H:S 列复制到另一个电子表格。
function movePros() {
var date = Utilities.formatDate(new Date, "CST", "yyyy-MM-dd'T'HH:mm:ss'Z'") //"MM/dd/yyyy"
var source = SpreadsheetApp.getActiveSpreadsheet();
var target = SpreadsheetApp.openById("0ApBdJlRcFy9XdGx0aXRabWlweGxyY3czZzZIemVla3c");
var lastRow = source.getLastRow();
var sheet = source.getSheetByName("City");
var data = sheet.getDataRange.getValues(); //This makes an array, right?
Browser.msgBox(data.slice(1))
// I've tried, but still don't know how get at the individual cell values so that I can both check them and write them in the correct order which is different than the source
var prospect=[DateCalled,PriceSurvey,VolSurvey,Company,Phone,Contact,OdmNotes,Address,City,State,Zip,County,Sic,"","","","","","","","=IFERROR(IF(INDIRECT(\"W\"&ROW())<>\"\",TEXT(INDIRECT(\"W\"&ROW()),\"yyyyww\")+0,IF(INDIRECT(\"T\"&ROW())<>\"\",TEXT(INDIRECT(\"T\"&ROW()),\"yyyyww\")+0,IF(INDIRECT(\"A\"&ROW())<>\"\",TEXT(INDIRECT(\"A\"&ROW()),\"yyyyww\")+1,\"\"))),\"\")","U","","","","","",ODM,"",""];
// var prospect=[data()[0]..... ugh, I don/'t know....
/*
var ODM = sheet.getRange("A"+i).getValues();
var DateCalled = sheet.getRange("B"+i).getValues();
var PriceSurvey = sheet.getRange("H"+i).getValues();
var VolSurvey = sheet.getRange("I"+i).getValues();
var Company = sheet.getRange("J"+i).getValues();
var Phone = sheet.getRange("K1"+i).getValues();
var Contact = sheet.getRange("L"+i).getValues();
var OdmNotes = sheet.getRange("M"+i).getValues();
var Address = sheet.getRange("N"+i).getValues();
var City = sheet.getRange("O"+i).getValues();
var State = sheet.getRange("P"+i).getValues();
var Zip = sheet.getRange("Q"+i).getValues();
var County = sheet.getRange("R"+i).getValues();
var Sic = sheet.getRange("S"+i).getValues();
*/
while (i <= lastRow) {
var i = 2
if (sheet.getRange("G"+i).getValue()==1 && sheet.getRange("U"+i).getValue()=="") { //cheking
target.appendRow(prospect);
source.getRange("U"+i).setValue(date);
i++;
} else {
i++;
}
}
}