ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check if a String is inside an Array (https://www.excelbanter.com/excel-programming/276006-re-check-if-string-inside-array.html)

Alan Beban[_3_]

Check if a String is inside an Array
 
No; but if the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, the coding
can look simpler (the looping is within the function):

Replace the loop with
If ArrayCountIf(MyArray, A) 0 Then _
MsgBox "it's there" Else MsgBox "it's not"

Alan Beban

Luis Carrion wrote:
Hi,
If I were to check if a variable: A="Test" is inside a list of
possible strings,Iīll do this:

Dim A as string
Dim B as variant
Dim MyArray As variant

MyArray=Array("Test", "This")
For Each B in MyArray
If A=B then Msgbox "Itīs inside the group
Next A

Is it possible to test this in other way; something like this
If A is in/like MyArray then....... ---without looping inside the
array

Thanks.
LC




All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com