回答編集履歴
1
コード追記
test
CHANGED
@@ -17,3 +17,55 @@
|
|
17
17
|
古いバージョンなら、CTRL+SHIFT+ENTER で配列数式にしたらいけるかも知れない。
|
18
18
|
|
19
19
|
(環境がないので確認はしてない。)
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
最近のバージョンなら下記でもいける。
|
24
|
+
|
25
|
+
```EXCEL
|
26
|
+
|
27
|
+
=XLOOKUP(1,COUNTIF(A2,"*"&$C$2:$C$100&"*"),$C$2:$C$100,"",2)
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
---
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
VBAのサンプル
|
38
|
+
|
39
|
+
```vba
|
40
|
+
|
41
|
+
Private Sub ExtractKeyword()
|
42
|
+
|
43
|
+
Dim rng As Range
|
44
|
+
|
45
|
+
Set rng = Range("A1").CurrentRegion '表範囲
|
46
|
+
|
47
|
+
Set rng = Intersect(rng, rng.Offset(1)) '見出し行を除く
|
48
|
+
|
49
|
+
Dim c As Range
|
50
|
+
|
51
|
+
For Each c In rng.Columns(1).Cells
|
52
|
+
|
53
|
+
Dim keyword As Range
|
54
|
+
|
55
|
+
For Each keyword In rng.Columns(3).Cells
|
56
|
+
|
57
|
+
If c Like "*" & keyword.Value & "*" Then
|
58
|
+
|
59
|
+
c.Offset(, 1).Value = keyword.Value
|
60
|
+
|
61
|
+
Exit For
|
62
|
+
|
63
|
+
End If
|
64
|
+
|
65
|
+
Next
|
66
|
+
|
67
|
+
Next
|
68
|
+
|
69
|
+
End Sub
|
70
|
+
|
71
|
+
```
|