title: Matching values in string array
body: <p>Problem: Looking for a more efficient way of finding whether there is an exact matching value in a 1d array -- essentially a boolean <code>true/false</code>.</p>
  
  <p><strong>Am I overlooking something obvious?</strong> Or am I simply using the wrong data structure, by using an array when I probably should be using a collection object or a dictionary?  In the latter I could check the <code>.Contains</code> or <code>.Exists</code> method, respectively</p>
  
  <p>In Excel I can check for a value in a vector array like:</p>
  
  <pre><code>If Not IsError(Application.Match(strSearch, varToSearch, False)) Then
  ' Do stuff
  End If
  </code></pre>
  
  <p>This returns an exact match index, obviously subject to limitations of <code>Match</code> function which only finds the <em>first</em> matching value in this context. This is a commonly used method, and one that I have been using for a long time, too.</p>
  
  <p><strong>This is satisfactory enough for Excel -- but what about other applications?</strong></p>
  
  <p>In other applications, I can do basically the same thing but requires enabling reference to the Excel object library, and then:</p>
  
  <pre><code>   If Not IsError(Excel.Application.match(...))
  </code></pre>
  
  <p>That seems silly, though, and is difficult to manage on distributed files because of permissions/trust center/etc.</p>
  
  <p>I have tried to use the <a href="http://msdn.microsoft.com/en-us/library/fat7fw0s%28v=vs.90%29.aspx">Filter()</a> function:</p>
  
  <pre><code> If Not Ubound(Filter(varToSearch, strSearch)) = -1 Then
      'do stuff
   End If
  </code></pre>
  
  <p>But the problem with this approach is that <code>Filter</code> returns an array of partial matches, rather than an array of exact matches.  (I have no idea why it would be useful to return substring/partial matches.)  </p>
  
  <p>The other alternative is to literally iterate over each value in the array (this also is very commonly used I think) -- which seems even more needlessly cumbersome than calling on Excel's <code>Match</code> function.</p>
  
  <pre><code>For each v in vArray
     If v = strSearch Then
      ' do stuff
     End If
  Next
  </code></pre>