こういうことでしょうか?(動作未確認)
VBA
1Sub NegForm_Check()
2
3 Dim r As Long
4 Dim r2 As Long
5 Dim rowmax As Long
6 Dim shTXT As Worksheet ' テキストシート
7 Dim shKW As Worksheet ' キーワードシート
8
9 Set shTXT = Worksheets("sheet1")
10 Set shKW = Worksheets("sheet2")
11
12 rowmax = shTXT.Range("A11").End(xlDown).Row
13
14 For r = 11 To rowmax
15 r2 = 1
16 Do While shKW.Cells(r2, 1) <> ""
17 If LCase(shTXT.Cells(r, 1).Value) Like "*" & LCase(shKW.Cells(r2, 1).Value) & "*" Then
18 If Not shTXT.Cells(r, 2).Value Like "*" & shKW.Cells(r2, 2).Value & "*" Then
19 shTXT.Cells(r, 3).Value = "NG"
20 shTXT.Cells(r, 3).Font.ColorIndex = 3
21 Exit Do
22 End If
23 End If
24 r2 = r2 + 1
25 Loop
26 Next r
27
28End Sub
コメントに書いた、1セルにカンマ区切りで詰め込んだ場合のを作ってみました。
VBA
1Sub NegForm_Check()
2
3 Dim r As Long
4 Dim r2 As Long
5 Dim rowmax As Long
6 Dim shTXT As Worksheet ' テキストシート
7 Dim shKW As Worksheet ' キーワードシート
8 Dim flg As Boolean
9
10 Set shTXT = Worksheets("sheet1")
11 Set shKW = Worksheets("sheet2")
12
13 rowmax = shTXT.Range("A11").End(xlDown).Row
14
15 For r = 11 To rowmax
16 r2 = 1
17 Do While shKW.Cells(r2, 1) <> ""
18 If LCase(shTXT.Cells(r, 1).Value) Like "*" & LCase(shKW.Cells(r2, 1).Value) & "*" Then
19 flg = False
20 Dim words() As String
21 words = Split(shKW.Cells(r2, 2).Value, ",")
22 For Each word In words
23 If shTXT.Cells(r, 2).Value Like "*" & word & "*" Then
24 flg = True
25 Exit For
26 End If
27 Next
28 If Not flg Then
29 shTXT.Cells(r, 3).Value = "NG"
30 shTXT.Cells(r, 3).Font.ColorIndex = 3
31 Exit Do
32 End If
33 End If
34 r2 = r2 + 1
35 Loop
36 Next r
37
38End Sub
39