I hope you are great! I want to search through a VBA ArrayList and get the index number, the problem is, with For loop, you can only get the exact matches’ index. I have the most of my search element (highlighted in the red box) and I want to get the elements which highlighted in the blue box, is there any way to do this in VBA?
You can use the in-built function
InStr to find an occurrence of one string inside another.
In your case change this:
If list(j) = search_element Then
If InStr(1, list(j), search_element) > 0 Then
InStr returns the position of
list(j). If the position is above 0 then the string was found. If it is
0 then nothing was found.
Therefore, this will be
search_element occurs anywhere within
The documentation for
InStr is here.