excel vba Imitating the “IN” operator from python

The solution for “excel vba Imitating the “IN” operator from python” can be found here. The following code will assist you in solving the problem.

‘VBA does not have an IN operator, but we can do this:

Function IsIn(a, b) As Boolean
IsIn = InStr(“,” & b & “,”, “,” & a & “,”)
End Function


MsgBox IsIn(2, “1,2,3”) ‘<-- displays True MsgBox IsIn("d", "a,b,c") '<-- displays False

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts