StringContainsAny

Returns whether a string contains at least one of several strings.

Syntax: StringContainsAny ( haystack, caseSensitive [, needles ] ) As Boolean

haystack
required The String to search.
caseSensitive
required A Boolean. When False the comparison ignores letter case. When True it compares the characters exactly. It comes before the list of strings and cannot be left out.
needles
optional Any number of values, each of which is converted to a String and looked for in haystack. This is a ParamArray of Variant.

Returns True when at least one of needles occurs in haystack, and False otherwise.

Remarks

The function passes each needle in turn to StringContains and returns True at the first one that is found, so later needles are not tried. With no needles the result is False.

Example

Debug.Print StringContainsAny("Hello", False, "x", "L")  ' True
Debug.Print StringContainsAny("Hello", True, "x", "L")   ' False
Debug.Print StringContainsAny("Hello", True, "x", "l")   ' True
Debug.Print StringContainsAny("Hello", False)            ' False

See Also