이번 주에 질문 된 내용은 similar question입니다.
시트와 제목의 이름을 변경해야하지만 여기에 제 제안이 있습니다.
function setCommon() {
var ss = SpreadsheetApp.getActive(),
compare1 = "", compare2 = "",
outputSheet = ss.getSheetByName("Sheet1"),
sourceSheet = ss.getSheetByName("Sheet2"),
range1 = outputSheet.getDataRange(),
range2 = sourceSheet.getDataRange(),
lastCol1 = range1.getNumColumns(),
lastCol2 = range2.getNumColumns(),
values1 = range1.getValues(),
values2 = range2.getValues(),
// get the range of the titles
titleSection1 = outputSheet.getRange(1,1,1, lastCol1),
titleSection2 = sourceSheet.getRange(1,1,1, lastCol2),
// get the values from the titles
titles1 = titleSection1.getValues(),
titles2 = titleSection2.getValues(),
// get the column # for "ID" and "comment"
idCol1 = titles1[0].indexOf("ID"),
idCol2 = titles2[0].indexOf("ID"),
commentsCol1 = titles1[0].indexOf("comment"),
commentsCol2 = titles2[0].indexOf("comment");
// get the IDs from range1
for (i = 1; i < values1.length; i++) {
compare1 = values1[i][idCol1];
// get the IDs from range2
for (j = 1; j< values2.length; j++){
compare2 = values2[j][idCol2];
// if same ID, change the values array
if (compare1 == compare2) {
values1[i][commentsCol1] = values2[j][commentsCol2];
}
}
}
// set values based on the values array
range1.setValues(values1);
}
멋진 프로젝트입니다. 뭔가에 대해 궁금한 점이 있으면 알려주십시오. –
안녕 앙투안, 고마워! 내가 명시 적으로 질문하지 않았다는 것을 깨달았습니다. 이 일을 가장 잘 수행하는 방법을 찾고 싶습니다. 몇 가지 방법을 시도했지만 아무 소용이 없습니다. –
이봐, 나는 당신이 downvotes을 받고 있다고보고, 여기 [더 나은 질문을하는 방법에 대한 안내] (http://catb.org/~esr/faqs/smart-questions.html)입니다. 스택 오버플로 및 기타 장소에 적용됩니다. –