回答編集履歴
7
修正
test
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
' Set TM = Workbooks.Open(TenkiMoto & "\テスト\転記元.xlsm") '転記元ファイル名を変数格納
|
10
|
+
|
11
|
+
Set TM = ThisWorkbook 'このマクロがあるファイルが転記元
|
10
12
|
|
11
13
|
Set TS = Workbooks.Open(TenkiSaki & "\転記先.xlsx") '転記先ファイル名を変数格納
|
12
14
|
|
6
修正
test
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
```VBA
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
Set TM = Workbooks.Open(TenkiMoto & "\テスト\転記元.xlsm") '転記元ファイル名を変数格納
|
10
|
+
|
11
|
+
Set TS = Workbooks.Open(TenkiSaki & "\転記先.xlsx") '転記先ファイル名を変数格納
|
12
|
+
|
13
|
+
|
6
14
|
|
7
15
|
Set wsM = TM.Worksheets(1) '転記元シートを変数格納
|
8
16
|
|
5
修正
test
CHANGED
@@ -1,26 +1,6 @@
|
|
1
1
|
これでどうでしょうか。
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
```VBA
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
resultS = wsS.Range("A2").Resize(lastrowS - 1, 2).Find(numberM, lookat:=xlWhole)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
```
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
---
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
(追記)
|
24
4
|
|
25
5
|
```VBA
|
26
6
|
|
4
修正
test
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
|
25
25
|
```VBA
|
26
26
|
|
27
|
-
Set wsM =
|
27
|
+
Set wsM = TM.Worksheets(1) '転記元シートを変数格納
|
28
28
|
|
29
|
-
Set wsS =
|
29
|
+
Set wsS = TS.Worksheets(1) '転記先シートを変数格納
|
30
30
|
|
31
31
|
|
32
32
|
|
3
追記
test
CHANGED
@@ -24,6 +24,12 @@
|
|
24
24
|
|
25
25
|
```VBA
|
26
26
|
|
27
|
+
Set wsM = Workbooks(TM).Worksheets(1) '転記元シートを変数格納
|
28
|
+
|
29
|
+
Set wsS = Workbooks(TS).Worksheets(1) '転記先シートを変数格納
|
30
|
+
|
31
|
+
|
32
|
+
|
27
33
|
lastrowM = wsM.Cells(wsM.Rows.Count, 1).End(xlUp).Row '転記元シート最終行数抽出
|
28
34
|
|
29
35
|
lastrowS = wsS.Cells(wsS.Rows.Count, 1).End(xlUp).Row '転記先シート最終行数抽出
|
2
追記
test
CHANGED
@@ -13,3 +13,35 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
```
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
(追記)
|
24
|
+
|
25
|
+
```VBA
|
26
|
+
|
27
|
+
lastrowM = wsM.Cells(wsM.Rows.Count, 1).End(xlUp).Row '転記元シート最終行数抽出
|
28
|
+
|
29
|
+
lastrowS = wsS.Cells(wsS.Rows.Count, 1).End(xlUp).Row '転記先シート最終行数抽出
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
For i = 2 To lastrowM '転記元検索値が存在するまで繰り返す
|
34
|
+
|
35
|
+
numberM = wsM.Cells(i, 2).Value '転記元検索値を変数格納
|
36
|
+
|
37
|
+
If WorksheetFunction.CountIf(wsS.Range("A2").Resize(lastrowS - 1, 1), numberM) = 0 Then
|
38
|
+
|
39
|
+
lastrowS = lastrowS + 1
|
40
|
+
|
41
|
+
wsS.Cells(lastrowS, 1) = numberM
|
42
|
+
|
43
|
+
End If
|
44
|
+
|
45
|
+
Next i
|
46
|
+
|
47
|
+
```
|
1
修正
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
resultS = wsS.Range("A2").Resize(lastrow
|
11
|
+
resultS = wsS.Range("A2").Resize(lastrowS - 1, 2).Find(numberM, lookat:=xlWhole)
|
12
12
|
|
13
13
|
|
14
14
|
|