Всем привет! В общем такая проблема, есть массив с определенными словами и есть таблица с предложениями. Мне нужно в каждом предложении делать неточный поиск любого слова из массива и если хоть что-то находится - подставлять да или нет. Пример файл прикладываю.
Sub iWordMassivRed()
Dim i As Long
Dim j As Integer
Dim n As Integer
Dim iLR As Long
Dim iLastRow As Long
Dim re As Object
Dim objMatches As Object
Dim objMatch As Object
iLR = Cells(1, 1).End(xlDown).Row
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:A" & iLR).Font.ColorIndex = 0
For n = 11 To iLastRow
Set re = CreateObject("VBScript.RegExp")
re.Global = True
re.IgnoreCase = True
re.Pattern = Cells(n, "A")
For i = 2 To iLR
Set objMatches = re.Execute(Cells(i, "A"))
If objMatches.Count <> 0 Then
For j = 0 To objMatches.Count - 1
Set objMatch = objMatches.Item(j)
With Cells(i, "A").Characters(Start:=objMatch.FirstIndex + 1, Length:=objMatch.Length).Font
.ColorIndex = 3
End With
Next
End If
Next
Set re = Nothing
Next
End Sub
Function ContainsOneOfThese(stringRange As Range, substringsRange As Range) As String
Dim inString As String
Dim substringsArray As Variant
inString = stringRange.Value
substringsArray = substringsRange.Value
For i = LBound(substringsArray) To UBound(substringsArray)
If InStr(inString, substringsArray(i, 1)) > 0 Then
ContainsOneOfThese = "Да"
Exit Function
End If
Next i
ContainsOneOfThese = "Нет"
End Function