回答編集履歴
2
セル詰め込み版
answer
CHANGED
@@ -29,4 +29,46 @@
|
|
29
29
|
Next r
|
30
30
|
|
31
31
|
End Sub
|
32
|
+
```
|
33
|
+
コメントに書いた、1セルにカンマ区切りで詰め込んだ場合のを作ってみました。
|
34
|
+
```VBA
|
35
|
+
Sub NegForm_Check()
|
36
|
+
|
37
|
+
Dim r As Long
|
38
|
+
Dim r2 As Long
|
39
|
+
Dim rowmax As Long
|
40
|
+
Dim shTXT As Worksheet ' テキストシート
|
41
|
+
Dim shKW As Worksheet ' キーワードシート
|
42
|
+
Dim flg As Boolean
|
43
|
+
|
44
|
+
Set shTXT = Worksheets("sheet1")
|
45
|
+
Set shKW = Worksheets("sheet2")
|
46
|
+
|
47
|
+
rowmax = shTXT.Range("A11").End(xlDown).Row
|
48
|
+
|
49
|
+
For r = 11 To rowmax
|
50
|
+
r2 = 1
|
51
|
+
Do While shKW.Cells(r2, 1) <> ""
|
52
|
+
If LCase(shTXT.Cells(r, 1).Value) Like "*" & LCase(shKW.Cells(r2, 1).Value) & "*" Then
|
53
|
+
flg = False
|
54
|
+
Dim words() As String
|
55
|
+
words = Split(shKW.Cells(r2, 2).Value, ",")
|
56
|
+
For Each word In words
|
57
|
+
If shTXT.Cells(r, 2).Value Like "*" & word & "*" Then
|
58
|
+
flg = True
|
59
|
+
Exit For
|
60
|
+
End If
|
61
|
+
Next
|
62
|
+
If Not flg Then
|
63
|
+
shTXT.Cells(r, 3).Value = "NG"
|
64
|
+
shTXT.Cells(r, 3).Font.ColorIndex = 3
|
65
|
+
Exit Do
|
66
|
+
End If
|
67
|
+
End If
|
68
|
+
r2 = r2 + 1
|
69
|
+
Loop
|
70
|
+
Next r
|
71
|
+
|
72
|
+
End Sub
|
73
|
+
|
32
74
|
```
|
1
修正
answer
CHANGED
@@ -17,8 +17,8 @@
|
|
17
17
|
For r = 11 To rowmax
|
18
18
|
r2 = 1
|
19
19
|
Do While shKW.Cells(r2, 1) <> ""
|
20
|
-
If LCase(shTXT.Cells(r, 1).Value) Like "*" & shKW.Cells(r2, 1) & "*" Then
|
20
|
+
If LCase(shTXT.Cells(r, 1).Value) Like "*" & LCase(shKW.Cells(r2, 1).Value) & "*" Then
|
21
|
-
If Not shTXT.Cells(r, 2).Value Like "*" & shKW.Cells(r2, 2) & "*" Then
|
21
|
+
If Not shTXT.Cells(r, 2).Value Like "*" & shKW.Cells(r2, 2).Value & "*" Then
|
22
22
|
shTXT.Cells(r, 3).Value = "NG"
|
23
23
|
shTXT.Cells(r, 3).Font.ColorIndex = 3
|
24
24
|
Exit Do
|