回答編集履歴
1
追記
test
CHANGED
@@ -1 +1,61 @@
|
|
1
1
|
このコードにおいて ws はVariant(実質String)であってWorksheet型ではない、ということでは。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```VBA
|
6
|
+
|
7
|
+
Sub データ戻す用()
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
With Workbooks("A.xlsm").Worksheets(2)
|
12
|
+
|
13
|
+
Dim k As Variant, o As Range, v As Variant
|
14
|
+
|
15
|
+
k = .Range("A2:A100001").Value
|
16
|
+
|
17
|
+
Set o = .Range("L2:L100001")
|
18
|
+
|
19
|
+
v = o.Value
|
20
|
+
|
21
|
+
End With
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
With Workbooks.Open("B.xlsx")
|
26
|
+
|
27
|
+
Dim n As Variant, w As Worksheet, s As Variant, i As Long
|
28
|
+
|
29
|
+
For Each n In Array("aa", "bb", "cc", "dd", "ee", "ff")
|
30
|
+
|
31
|
+
Set w = .Worksheets(n)
|
32
|
+
|
33
|
+
'w.ShowAllData
|
34
|
+
|
35
|
+
s = w.Range("A2:Q100001").Value
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
For i = 1 To UBound(k, 1)
|
40
|
+
|
41
|
+
v(i, 1) = WorksheetFunction.VLookup(k(i, 1), s, 17, False)
|
42
|
+
|
43
|
+
Next i
|
44
|
+
|
45
|
+
Next n
|
46
|
+
|
47
|
+
'.Close False
|
48
|
+
|
49
|
+
End With
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
o.Value = v
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
End Sub
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```
|