title: Excel VBA CMD to List Directory Contents
body: <p>How would I modify this Excel VBA to:</p>
  
  <ol>
  <li>List the paths of the directories and not just the files?</li>
  <li>Filter out system and hidden files?</li>
  </ol>
  
  <p>Here is the the current VBA:</p>
  
  <pre><code>Sub MM()
      Dim fResults As Variant
      fResults = GetFiles("C:\Temp")
      Range("A1").Resize(UBound(fResults) + 1, 1).Value = _ 
      WorksheetFunction.Transpose(fResults)
  End Sub
  
  
  // UDF to populate array with files, assign to a Variant variable.
  Function GetFiles(parentFolder As String) As Variant
      GetFiles = Filter(Split(CreateObject("WScript.Shell").Exec("CMD /C DIR """ &amp; parentFolder &amp; _
          IIf(Right(parentFolder, 1) = "\", vbNullString, "\") &amp; "*.*"" /S /B /A:-D").StdOut.ReadAll, vbCrLf), ".")
  End Function
  </code></pre>