In this article we will learn about some of the frequently asked Visual Basic programming questions in technical like “excel vba multiple string search with InStr function” Code Answer. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error handling in VBA is simple. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in Visual Basic. Below are some solution about “excel vba multiple string search with InStr function” Code Answer.
excel vba multiple string search with InStr function
xxxxxxxxxx
1
'VBA function to check if ANY of a list of substrings is contained
2
'within a string:
3
4
Function AnyIn(s$, ParamArray checks()) As Boolean
5
Dim e
6
For Each e In checks
7
If InStrB(s, e) Then AnyIn = True: Exit Function
8
Next
9
End Function
10
11
'-------------------------------------------------------------------
12
13
MsgBox AnyIn("abcde", "o", 5, "z", "a") '<--displays: True
14
MsgBox AnyIn("abcde", "o", 5, "z", "p") '<--displays: False
15