title: Search a folder for keyword
body: <p>I'm looking to search a folder for a keyword term 'fuel', to pull information from returned files into a 'data' sheet.</p>
  <p>For instance, I have a folder week numbers (1 - 52 cross the year so in the new year this will contain one folder but will build as the year goes on).<br />
  I search this folder for all .doc files contains the word 'fuel'.<br />
  You can do this via a Windows search by typing &quot;fuel&quot; in the search function in the top corner and it will display all filenames and all files that contains the word 'fuel'.</p>
  <p>I have this for searching for a file that has 'fuel' in its name, but not inside it.</p>
  <pre class="lang-vb prettyprint-override"><code>Sub LoopThroughFiles()
      Dim MyObj As Object, MySource As Object, file As Variant
      file = Dir(&quot;c:\testfolder\&quot;)
      While (file &lt;&gt; &quot;&quot;)
          If InStr(file, &quot;fuel&quot;) &gt; 0 Then
              MsgBox &quot;found &quot; &amp; file
              Exit Sub
          End If
          file = Dir
      Wend
  End Sub
  </code></pre>