回答編集履歴
3
コード修正
test
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
'参照先 A列からZ列まで(26列)
|
58
58
|
|
59
|
-
Const datalist = ",'C:\
|
59
|
+
Const datalist = ",'C:\test[tera330470_list.xlsx]Sheet1'!$A:$Z"
|
60
60
|
|
61
61
|
Const colCnt = 26
|
62
62
|
|
2
コード追記
test
CHANGED
@@ -41,3 +41,45 @@
|
|
41
41
|
End Sub
|
42
42
|
|
43
43
|
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
---
|
48
|
+
|
49
|
+
項目数が多いときはループにするといいでしょう。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
```vba
|
54
|
+
|
55
|
+
Private Sub Worksheet_Change(ByVal Target As Range)
|
56
|
+
|
57
|
+
'参照先 A列からZ列まで(26列)
|
58
|
+
|
59
|
+
Const datalist = ",'C:\Users\博幸\Documents[tera330470_list.xlsx]Sheet1'!$A:$Z"
|
60
|
+
|
61
|
+
Const colCnt = 26
|
62
|
+
|
63
|
+
'targetがA列でさらにデータ型が数値だった時
|
64
|
+
|
65
|
+
If (VarType(Target.Value) = 5 And Target.Column = 1) Then
|
66
|
+
|
67
|
+
Dim i As Long
|
68
|
+
|
69
|
+
For i = 2 To colCnt
|
70
|
+
|
71
|
+
With Target.Offset(, i - 1)
|
72
|
+
|
73
|
+
.Formula = "=VLOOKUP(" & Target.Address & datalist & "," & i & ",FALSE)"
|
74
|
+
|
75
|
+
.Value = .Value
|
76
|
+
|
77
|
+
End With
|
78
|
+
|
79
|
+
Next
|
80
|
+
|
81
|
+
End If
|
82
|
+
|
83
|
+
End Sub
|
84
|
+
|
85
|
+
```
|
1
コード修正
test
CHANGED
@@ -22,8 +22,6 @@
|
|
22
22
|
|
23
23
|
.Formula = "=VLOOKUP(" & Target.Address & datalist & ",2,FALSE)"
|
24
24
|
|
25
|
-
Debug.Print .Value
|
26
|
-
|
27
25
|
.Value = .Value
|
28
26
|
|
29
27
|
End With
|