Using VBA to retrieve Column Headers from Excel files
<p>I'm working with someone who has  to identify certain variables within excel files. Currently, the man I'm working with has a great deal of folders and sub-folders that have Excel documents in them. He's using a VBA code that looks within a folder for a sub-folder, and then returns the pathway, then creating a hyperlink to the sub-folder (this isn't part of the VBA code below) and looking at all excel files within, no matter the level of sub-folders within the main folder.</p>

<p>Here's the code:</p>

<pre><code>    Sub GetFolders()
Dim path As String
Dim folder As String
Dim row As Integer


path = "your directory here"
folder = Dir(path, vbDirectory)
row = 1

Do While folder &lt;&gt; ""
If (GetAttr(path &amp; folder) And vbDirectory) = vbDirectory Then
    Cells(row, 1) = path &amp; folder
    row = row + 1
End If
folder = Dir()
Loop

End Sub
</code></pre>

<p>This is great, but I know there has to be a better way. How can I manipulate this code to return COLUMN HEADERS of any excel files found A) within a folder or B) within a subfolder contained within a folder. I want these to be returned to an excel spreadsheet so that 100's of excel documents don't need to be opened, but rather just this one, and then we can identify any excel spreadsheets that need further investigation and ignore the rest.</p>