-
Notifications
You must be signed in to change notification settings - Fork 0
/
getMergedTable.js
35 lines (23 loc) · 1018 Bytes
/
getMergedTable.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 스태프 관리 시트 전용
function getMergedTable() {
var targetSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("table_merged");
var vstackFunc1 = "=VSTACK(";
var vstackFunc2 = "=VSTACK("
var row = 5;
while (targetSheet.getRange(row, 1).isBlank() == false) {
var compName = targetSheet.getRange(row, 1).getValue();
var queryString1 = "QUERY('" + compName + "'!A4:H, \"SELECT B, G WHERE (A contains 'TRUE')\")";
var queryString2 = "QUERY('" + compName + "'!H4:H, \"SELECT H WHERE H IS NOT NULL\")"
vstackFunc1 += queryString1;
vstackFunc1 += ", "
vstackFunc2 += queryString2;
vstackFunc2 += ", ";
row++;
}
vstackFunc1 = vstackFunc1.substring(0, vstackFunc1.length - 2);
vstackFunc1 += ")";
vstackFunc2 = vstackFunc2.substring(0, vstackFunc2.length - 2);
vstackFunc2 += ")";
targetSheet.getRange('C5').setFormula(vstackFunc1);
targetSheet.getRange('F5').setFormula(vstackFunc2);
}