回答編集履歴
9
修正
test
CHANGED
@@ -27,9 +27,9 @@
|
|
27
27
|
##### コピー元データの各列を詰めてコピー先に貼り付けたい場合
|
28
28
|
```js
|
29
29
|
function myFunction3() {
|
30
|
-
const sourceSheet = SpreadsheetApp.getActive().getSheetByName('
|
30
|
+
const sourceSheet = SpreadsheetApp.getActive().getSheetByName('ページ');
|
31
31
|
const sourceRangeList= sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
32
|
-
const destinationSheet = SpreadsheetApp.getActive().getSheetByName('
|
32
|
+
const destinationSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
33
33
|
let startColumn = 1;
|
34
34
|
const startRow = 2;
|
35
35
|
sourceRangeList.getRanges().forEach(range => {
|
8
test
CHANGED
@@ -13,10 +13,10 @@
|
|
13
13
|
```js
|
14
14
|
function myFunction2() {
|
15
15
|
const sourceSheet = SpreadsheetApp.getActive().getSheetByName('ページ');
|
16
|
-
const sourceRanges = sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
16
|
+
const sourceRangeList = sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
17
17
|
const destinationSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
18
18
|
|
19
|
-
sourceRanges.getRanges().forEach(range => {
|
19
|
+
sourceRangeList.getRanges().forEach(range => {
|
20
20
|
range.copyTo(destinationSheet.getRange(range.getA1Notation()), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
|
21
21
|
});
|
22
22
|
}
|
@@ -28,11 +28,11 @@
|
|
28
28
|
```js
|
29
29
|
function myFunction3() {
|
30
30
|
const sourceSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
31
|
-
const sourceRanges
|
31
|
+
const sourceRangeList= sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
32
32
|
const destinationSheet = SpreadsheetApp.getActive().getSheetByName('ページ');
|
33
33
|
let startColumn = 1;
|
34
34
|
const startRow = 2;
|
35
|
-
sourceRanges.getRanges().forEach(range => {
|
35
|
+
sourceRangeList.getRanges().forEach(range => {
|
36
36
|
const destinationRange = destinationSheet.getRange(startRow, startColumn, range.getNumRows(), range.getNumColumns());
|
37
37
|
range.copyTo(destinationRange, SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
|
38
38
|
startColumn += range.getNumColumns();
|
7
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
```js
|
14
14
|
function myFunction2() {
|
15
|
-
|
15
|
+
const sourceSheet = SpreadsheetApp.getActive().getSheetByName('ページ');
|
16
|
-
|
16
|
+
const sourceRanges = sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
17
|
-
|
17
|
+
const destinationSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
18
18
|
|
19
19
|
sourceRanges.getRanges().forEach(range => {
|
20
20
|
range.copyTo(destinationSheet.getRange(range.getA1Notation()), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
|
@@ -27,9 +27,9 @@
|
|
27
27
|
##### コピー元データの各列を詰めてコピー先に貼り付けたい場合
|
28
28
|
```js
|
29
29
|
function myFunction3() {
|
30
|
-
|
30
|
+
const sourceSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
31
|
-
|
31
|
+
const sourceRanges = sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
32
|
-
|
32
|
+
const destinationSheet = SpreadsheetApp.getActive().getSheetByName('ページ');
|
33
33
|
let startColumn = 1;
|
34
34
|
const startRow = 2;
|
35
35
|
sourceRanges.getRanges().forEach(range => {
|
6
修正
test
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
let startColumn = 1;
|
34
34
|
const startRow = 2;
|
35
35
|
sourceRanges.getRanges().forEach(range => {
|
36
|
-
const destinationRange = destinationSheet.getRange(startRow, startColumn, range.getNum
|
36
|
+
const destinationRange = destinationSheet.getRange(startRow, startColumn, range.getNumRows(), range.getNumColumns());
|
37
37
|
range.copyTo(destinationRange, SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
|
38
38
|
startColumn += range.getNumColumns();
|
39
39
|
});
|
5
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
----
|
26
26
|
|
27
|
-
# コピー元データの各列を詰めてコピー先に貼り付けたい場合
|
27
|
+
##### コピー元データの各列を詰めてコピー先に貼り付けたい場合
|
28
28
|
```js
|
29
29
|
function myFunction3() {
|
30
30
|
var sourceSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
4
追記
test
CHANGED
@@ -22,3 +22,20 @@
|
|
22
22
|
}
|
23
23
|
```
|
24
24
|
|
25
|
+
----
|
26
|
+
|
27
|
+
# コピー元データの各列を詰めてコピー先に貼り付けたい場合
|
28
|
+
```js
|
29
|
+
function myFunction3() {
|
30
|
+
var sourceSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
31
|
+
var sourceRanges = sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
32
|
+
var destinationSheet = SpreadsheetApp.getActive().getSheetByName('ページ');
|
33
|
+
let startColumn = 1;
|
34
|
+
const startRow = 2;
|
35
|
+
sourceRanges.getRanges().forEach(range => {
|
36
|
+
const destinationRange = destinationSheet.getRange(startRow, startColumn, range.getNumColumns(), range.getNumRows());
|
37
|
+
range.copyTo(destinationRange, SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
|
38
|
+
startColumn += range.getNumColumns();
|
39
|
+
});
|
40
|
+
}
|
41
|
+
```
|
3
test
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
> Exception: Invalid argument: a1Notations というエラー
|
2
2
|
|
3
3
|
getRangeList('ページ!'['A2:A', 'E2:E', 'H2:H', 'K2:K']) という指定方法はできません。
|
4
|
-
これだと「ページ!」という文字列に対して「'A2:A', 'E2:E', 'H2:H', 'K2:K'」というプロパティを指定しているので、undefined と評価され、引数として
|
4
|
+
これだと「ページ!」という文字列に対して「'A2:A', 'E2:E', 'H2:H', 'K2:K'」というプロパティを指定しているので、undefined と評価され、引数として無効(invalid)になります。
|
5
5
|
|
6
6
|
そもそもgetRangeList(['ページ!A2:A', 'ページ!E2:E', 'ページ!H2:H', 'ページ!K2:K']);
|
7
7
|
という指定方法もできません。
|
2
test
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
> Exception: Invalid argument: a1Notations というエラー
|
2
2
|
|
3
3
|
getRangeList('ページ!'['A2:A', 'E2:E', 'H2:H', 'K2:K']) という指定方法はできません。
|
4
|
-
これだと「ページ!」という文字列に対して「'A2:A', 'E2:E', 'H2:H', 'K2:K'」というプロパティを指定しているので、undefined と評価され、引数として不正
|
4
|
+
これだと「ページ!」という文字列に対して「'A2:A', 'E2:E', 'H2:H', 'K2:K'」というプロパティを指定しているので、undefined と評価され、引数として不正(invalid)になります。
|
5
5
|
|
6
6
|
そもそもgetRangeList(['ページ!A2:A', 'ページ!E2:E', 'ページ!H2:H', 'ページ!K2:K']);
|
7
7
|
という指定方法もできません。
|
1
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
```js
|
14
14
|
function myFunction2() {
|
15
|
-
var sourceSheet = SpreadsheetApp.getActive().getSheetByName('
|
15
|
+
var sourceSheet = SpreadsheetApp.getActive().getSheetByName('ページ');
|
16
16
|
var sourceRanges = sourceSheet.getRangeList(['A2:B', 'E2:E', 'H2:H', 'K2:K']);
|
17
|
-
var destinationSheet = SpreadsheetApp.getActive().getSheetByName('
|
17
|
+
var destinationSheet = SpreadsheetApp.getActive().getSheetByName('全体');
|
18
18
|
|
19
19
|
sourceRanges.getRanges().forEach(range => {
|
20
20
|
range.copyTo(destinationSheet.getRange(range.getA1Notation()), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
|