title: Excel VBA get file list from current folder by type
body: <p>I have an excel macro to get the file list by type from current folder.</p>
  
  <pre><code>Sub getfilelistfromfolder()
  
  Dim varDirectory As Variant
  Dim flag As Boolean
  Dim i As Integer
  Dim strDirectory As String
  
  strDirectory = Application.ActiveWorkbook.Path &amp; "\"
  i = 1
  flag = True
  varDirectory = Dir("C:\Macro\*.txt", vbNormal)
  
  While flag = True
      If varDirectory = "" Then
          flag = False
      Else
          Cells(i + 1, 1) = varDirectory
          varDirectory = Dir
          i = i + 1
      End If
  Wend
  End Sub
  </code></pre>
  
  <p>This works fine. But I want to make two modifications:
  1. Change the path name in </p>
  
  <pre><code>varDirectory = Dir("C:\Macro\*.txt", vbNormal)
  </code></pre>
  
  <p>to active workbook path. When I tried to change it and I got errors. I don't know how to combine </p>
  
  <blockquote>
    <p>Application.ActiveWorkbook.Path &amp; "\"</p>
  </blockquote>
  
  <p>with the .txt file type condition.</p>
  
  <ol start="2">
  <li>I want to print the results in cells  starting from B2, B3, B4...</li>
  </ol>
  
  <p>Could somebody please help me fix these two issues?
  Thanks in advance.</p>