回答編集履歴
1
a
test
CHANGED
@@ -6,45 +6,45 @@
|
|
6
6
|
|
7
7
|
const q375824 = () => {
|
8
8
|
|
9
|
-
const sheetName = `
|
9
|
+
const sheetName = `シート1`;
|
10
10
|
|
11
|
-
const sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
|
11
|
+
const sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
|
12
12
|
|
13
|
-
const values = sheet.getDataRange().getValues();
|
13
|
+
const values = sheet.getDataRange().getValues();
|
14
14
|
|
15
|
-
const colBAll = values.map(([,e])=>[e]).slice(1);
|
15
|
+
const colBAll = values.map(([,e])=>[e]).slice(1);
|
16
16
|
|
17
|
-
const terminate = colBAll.findIndex(e=>e[0] === "");
|
17
|
+
const terminate = colBAll.findIndex(e=>e[0] === "");
|
18
18
|
|
19
|
-
const colBs = colBAll.slice(0,terminate+1);
|
19
|
+
const colBs = terminate !== -1 ? colBAll.slice(0,terminate+1) : colBAll.slice(0);
|
20
20
|
|
21
|
-
const formattedDate = Utilities.formatDate(colBs[0][0],"Asia/Tokyo","M/dd");
|
21
|
+
const formattedDate = Utilities.formatDate(colBs[0][0],"Asia/Tokyo","M/dd");
|
22
22
|
|
23
|
-
const finder = sheet.createTextFinder(formattedDate);
|
23
|
+
const finder = sheet.createTextFinder(formattedDate);
|
24
24
|
|
25
|
-
const matchedDates = finder.findAll();
|
25
|
+
const matchedDates = finder.findAll();
|
26
26
|
|
27
|
-
if(matchedDates.length !== 2) {
|
27
|
+
if(matchedDates.length !== 2) {
|
28
28
|
|
29
|
-
console.log("wrong calendar settings");
|
29
|
+
console.log("wrong calendar settings");
|
30
30
|
|
31
|
-
return;
|
31
|
+
return;
|
32
32
|
|
33
|
-
}
|
33
|
+
}
|
34
34
|
|
35
|
-
const targetColumn = matchedDates[1].getColumn();
|
35
|
+
const targetColumn = matchedDates[1].getColumn();
|
36
36
|
|
37
|
-
const colPrevious = values.map(e=>[e[targetColumn-2]]).slice(1);
|
37
|
+
const colPrevious = values.map(e=>[e[targetColumn-2]]).slice(1);
|
38
38
|
|
39
|
-
if(isSame(colBs.slice(1),colPrevious.slice(1))) {
|
39
|
+
if(isSame(colBs.slice(1),colPrevious.slice(1))) {
|
40
40
|
|
41
|
-
console.log("same data");
|
41
|
+
console.log("same data");
|
42
42
|
|
43
|
-
return;
|
43
|
+
return;
|
44
44
|
|
45
|
-
}
|
45
|
+
}
|
46
46
|
|
47
|
-
sheet.getRange(2,targetColumn,colBs.length,1).setValues(colBs);
|
47
|
+
sheet.getRange(2,targetColumn,colBs.length,1).setValues(colBs);
|
48
48
|
|
49
49
|
}
|
50
50
|
|