回答編集履歴
3
追記
test
CHANGED
@@ -5,3 +5,101 @@
|
|
5
5
|
検索表を行ごとに読んで、同じようにKeyを作り、そのKEYで辞書から探し、
|
6
6
|
|
7
7
|
見つかったらそれを書く、見つからなければその旨書く
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
```VBA
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
Sub sample()
|
18
|
+
|
19
|
+
Dim ws As Worksheet
|
20
|
+
|
21
|
+
Set ws = ActiveSheet
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Dim dic As Scripting.Dictionary
|
26
|
+
|
27
|
+
Set dic = CreateObject("Scripting.Dictionary")
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
Dim 一致表 As Range
|
32
|
+
|
33
|
+
Set 一致表 = ws.Range("E1").CurrentRegion
|
34
|
+
|
35
|
+
With 一致表
|
36
|
+
|
37
|
+
Dim i, k, v
|
38
|
+
|
39
|
+
For i = 3 To .Rows.Count
|
40
|
+
|
41
|
+
k = TabJoin(.Cells(i, 1).Resize(, .Columns.Count - 1).Value)
|
42
|
+
|
43
|
+
v = .Cells(i, .Columns.Count).Value
|
44
|
+
|
45
|
+
dic.Add k, v
|
46
|
+
|
47
|
+
Next
|
48
|
+
|
49
|
+
End With
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
Dim 検索表 As Range
|
54
|
+
|
55
|
+
Set 検索表 = ws.Range("A1").CurrentRegion
|
56
|
+
|
57
|
+
With 検索表
|
58
|
+
|
59
|
+
Dim j, s, outCell As Range
|
60
|
+
|
61
|
+
For j = 3 To .Rows.Count
|
62
|
+
|
63
|
+
Set outCell = ws.Cells(.Rows.Count + j, 1)
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
s = TabJoin(.Rows(j).Value)
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
If dic.Exists(s) Then
|
72
|
+
|
73
|
+
outCell.Value = dic(s)
|
74
|
+
|
75
|
+
Else
|
76
|
+
|
77
|
+
outCell.Value = "入力する"
|
78
|
+
|
79
|
+
outCell.Interior.Color = vbYellow
|
80
|
+
|
81
|
+
End If
|
82
|
+
|
83
|
+
Next
|
84
|
+
|
85
|
+
ws.Cells(.Rows.Count + 2, 1).Value = "結果"
|
86
|
+
|
87
|
+
End With
|
88
|
+
|
89
|
+
End Sub
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
Function TabJoin(r)
|
94
|
+
|
95
|
+
With WorksheetFunction
|
96
|
+
|
97
|
+
' TabJoin = .TextJoin(vbTab, True, r)
|
98
|
+
|
99
|
+
TabJoin = Join(.Transpose(.Transpose(r)), vbTab)
|
100
|
+
|
101
|
+
End With
|
102
|
+
|
103
|
+
End Function
|
104
|
+
|
105
|
+
```
|
2
修正
test
CHANGED
@@ -5,89 +5,3 @@
|
|
5
5
|
検索表を行ごとに読んで、同じようにKeyを作り、そのKEYで辞書から探し、
|
6
6
|
|
7
7
|
見つかったらそれを書く、見つからなければその旨書く
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
---
|
12
|
-
|
13
|
-
```VBA
|
14
|
-
|
15
|
-
Sub sample()
|
16
|
-
|
17
|
-
Dim ws As Worksheet
|
18
|
-
|
19
|
-
Set ws = ActiveSheet
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
Dim dic As Scripting.Dictionary
|
24
|
-
|
25
|
-
Set dic = CreateObject("Scripting.Dictionary")
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Dim 一致表 As Range, i
|
30
|
-
|
31
|
-
Set 一致表 = ws.Range("E1").CurrentRegion
|
32
|
-
|
33
|
-
With 一致表
|
34
|
-
|
35
|
-
For i = 3 To .Rows.Count
|
36
|
-
|
37
|
-
dic.Add JoinUs(.Rows(i).Resize(, 3)), .Cells(i, 4).Value
|
38
|
-
|
39
|
-
Next
|
40
|
-
|
41
|
-
End With
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
Dim 検索表 As Range, j, t, outCell As Range
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Set 検索表 = ws.Range("A1").CurrentRegion
|
50
|
-
|
51
|
-
With 検索表
|
52
|
-
|
53
|
-
For j = 3 To .Rows.Count
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
Set outCell.Value = ws.Cells(.Rows.Count + j, 1)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
t = JoinUs(.Rows(j))
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
If dic.Exists(t) Then
|
66
|
-
|
67
|
-
outCell.Value = dic(t)
|
68
|
-
|
69
|
-
Else
|
70
|
-
|
71
|
-
outCell.Value = "入力する"
|
72
|
-
|
73
|
-
outCell.Interior.Color = vbYellow
|
74
|
-
|
75
|
-
End If
|
76
|
-
|
77
|
-
Next
|
78
|
-
|
79
|
-
End With
|
80
|
-
|
81
|
-
End Sub
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
Function JoinUs(r)
|
86
|
-
|
87
|
-
JoinUs = WorksheetFunction.TextJoin(vbTab, True, r)
|
88
|
-
|
89
|
-
End Function
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
```
|
1
追記
test
CHANGED
@@ -2,6 +2,92 @@
|
|
2
2
|
|
3
3
|
一致表を行ごとに読んで辞書にする(Keyは内容&項目&対応をつなげる、Itemは表示項目)
|
4
4
|
|
5
|
-
検索
|
5
|
+
検索表を行ごとに読んで、同じようにKeyを作り、そのKEYで辞書から探し、
|
6
6
|
|
7
7
|
見つかったらそれを書く、見つからなければその旨書く
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
```VBA
|
14
|
+
|
15
|
+
Sub sample()
|
16
|
+
|
17
|
+
Dim ws As Worksheet
|
18
|
+
|
19
|
+
Set ws = ActiveSheet
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Dim dic As Scripting.Dictionary
|
24
|
+
|
25
|
+
Set dic = CreateObject("Scripting.Dictionary")
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
Dim 一致表 As Range, i
|
30
|
+
|
31
|
+
Set 一致表 = ws.Range("E1").CurrentRegion
|
32
|
+
|
33
|
+
With 一致表
|
34
|
+
|
35
|
+
For i = 3 To .Rows.Count
|
36
|
+
|
37
|
+
dic.Add JoinUs(.Rows(i).Resize(, 3)), .Cells(i, 4).Value
|
38
|
+
|
39
|
+
Next
|
40
|
+
|
41
|
+
End With
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
Dim 検索表 As Range, j, t, outCell As Range
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
Set 検索表 = ws.Range("A1").CurrentRegion
|
50
|
+
|
51
|
+
With 検索表
|
52
|
+
|
53
|
+
For j = 3 To .Rows.Count
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
Set outCell.Value = ws.Cells(.Rows.Count + j, 1)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
t = JoinUs(.Rows(j))
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
If dic.Exists(t) Then
|
66
|
+
|
67
|
+
outCell.Value = dic(t)
|
68
|
+
|
69
|
+
Else
|
70
|
+
|
71
|
+
outCell.Value = "入力する"
|
72
|
+
|
73
|
+
outCell.Interior.Color = vbYellow
|
74
|
+
|
75
|
+
End If
|
76
|
+
|
77
|
+
Next
|
78
|
+
|
79
|
+
End With
|
80
|
+
|
81
|
+
End Sub
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
Function JoinUs(r)
|
86
|
+
|
87
|
+
JoinUs = WorksheetFunction.TextJoin(vbTab, True, r)
|
88
|
+
|
89
|
+
End Function
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
```
|