回答編集履歴
2
セル詰め込み版
test
CHANGED
@@ -61,3 +61,87 @@
|
|
61
61
|
End Sub
|
62
62
|
|
63
63
|
```
|
64
|
+
|
65
|
+
コメントに書いた、1セルにカンマ区切りで詰め込んだ場合のを作ってみました。
|
66
|
+
|
67
|
+
```VBA
|
68
|
+
|
69
|
+
Sub NegForm_Check()
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
Dim r As Long
|
74
|
+
|
75
|
+
Dim r2 As Long
|
76
|
+
|
77
|
+
Dim rowmax As Long
|
78
|
+
|
79
|
+
Dim shTXT As Worksheet ' テキストシート
|
80
|
+
|
81
|
+
Dim shKW As Worksheet ' キーワードシート
|
82
|
+
|
83
|
+
Dim flg As Boolean
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
Set shTXT = Worksheets("sheet1")
|
88
|
+
|
89
|
+
Set shKW = Worksheets("sheet2")
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
rowmax = shTXT.Range("A11").End(xlDown).Row
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
For r = 11 To rowmax
|
98
|
+
|
99
|
+
r2 = 1
|
100
|
+
|
101
|
+
Do While shKW.Cells(r2, 1) <> ""
|
102
|
+
|
103
|
+
If LCase(shTXT.Cells(r, 1).Value) Like "*" & LCase(shKW.Cells(r2, 1).Value) & "*" Then
|
104
|
+
|
105
|
+
flg = False
|
106
|
+
|
107
|
+
Dim words() As String
|
108
|
+
|
109
|
+
words = Split(shKW.Cells(r2, 2).Value, ",")
|
110
|
+
|
111
|
+
For Each word In words
|
112
|
+
|
113
|
+
If shTXT.Cells(r, 2).Value Like "*" & word & "*" Then
|
114
|
+
|
115
|
+
flg = True
|
116
|
+
|
117
|
+
Exit For
|
118
|
+
|
119
|
+
End If
|
120
|
+
|
121
|
+
Next
|
122
|
+
|
123
|
+
If Not flg Then
|
124
|
+
|
125
|
+
shTXT.Cells(r, 3).Value = "NG"
|
126
|
+
|
127
|
+
shTXT.Cells(r, 3).Font.ColorIndex = 3
|
128
|
+
|
129
|
+
Exit Do
|
130
|
+
|
131
|
+
End If
|
132
|
+
|
133
|
+
End If
|
134
|
+
|
135
|
+
r2 = r2 + 1
|
136
|
+
|
137
|
+
Loop
|
138
|
+
|
139
|
+
Next r
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
End Sub
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
```
|
1
修正
test
CHANGED
@@ -36,9 +36,9 @@
|
|
36
36
|
|
37
37
|
Do While shKW.Cells(r2, 1) <> ""
|
38
38
|
|
39
|
-
If LCase(shTXT.Cells(r, 1).Value) Like "*" & shKW.Cells(r2, 1) & "*" Then
|
39
|
+
If LCase(shTXT.Cells(r, 1).Value) Like "*" & LCase(shKW.Cells(r2, 1).Value) & "*" Then
|
40
40
|
|
41
|
-
If Not shTXT.Cells(r, 2).Value Like "*" & shKW.Cells(r2, 2) & "*" Then
|
41
|
+
If Not shTXT.Cells(r, 2).Value Like "*" & shKW.Cells(r2, 2).Value & "*" Then
|
42
42
|
|
43
43
|
shTXT.Cells(r, 3).Value = "NG"
|
44
44
|
|