title: Find all matches in workbook using Excel VBA
body: <p>I am trying to write a <code>VBA</code> routine that will take a string, search a given Excel workbook, and return to me all possible matches. </p>
  
  <p>I currently have an implementation that works, but it is extremely slow as it is a double for loop. Of course the built in Excel <code>Find</code> function is "optimized" to find a single match, but I would like it to return an array of initial matches that I can then apply further methods to. </p>
  
  <p>I will post some pseudocode of what I have already</p>
  
  <pre><code>For all sheets in workbook
      For all used rows in worksheet
          If cell matches search string
              do some stuff
          end
      end
  end
  </code></pre>
  
  <p>As previously stated, this double for loop makes things run very slowly, so I am looking to get rid of this if possible. Any suggestions?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>While the below answers would have improved my method, I ended up going with something slightly different as I needed to do multiple queries over and over.</p>
  
  <p>I instead decided to loop through all rows in my document and create a dictionary containing a key for each unique row. The value this points to will then be a list of possible matches, so that when I query later, I can simply just check if it exists, and if so, just get a quick list of matches. </p>
  
  <p>Basically just doing one initial sweep to store everything in a manageable structure, and then query that structure which can be done in <code>O(1)</code> time</p>