Это выполнимо в VBA?
Несомненно. Вот функция VBA помощник Я использую все время:
Public Function Contains(ByVal string_source As String, ByVal find_text As String, Optional ByVal caseSensitive As Boolean = False) As Boolean
Dim compareMethod As VbCompareMethod
If caseSensitive Then
compareMethod = vbBinaryCompare
Else
compareMethod = vbTextCompare
End If
Contains = (InStr(1, string_source, find_text, compareMethod) <> 0)
End Function
Я также использую это один всякий раз, когда у меня есть более чем одно значение для проверки - она работает лучше, чем делать If {check1} Or {check2} Or {check3}...
, потому что он возвращается, как только он находит совпадение , поэтому {check42}
не получить оценку, если {check1}
вернулся True
:
Public Function ContainsAny(ByVal string_source As String, ByVal caseSensitive As Boolean, ParamArray find_strings() As Variant) As Boolean
Dim find As String, i As Integer, found As Boolean
For i = LBound(find_strings) To UBound(find_strings)
find = CStr(find_strings(i))
found = Contains(string_source, find, caseSensitive)
If found Then Exit For
Next
ContainsAny = found
End Function
Приведите правильный пример – AHC
Похоже, что вы захотите использовать аналогичный оператор. https://msdn.microsoft.com/en-us/library/swf8kaxw.aspx – FairlyLegit