0

I am a non-programmer, and I need an automatic way to populate a column in Excel 2016 with filenames from a specific folder. I have never built macros before either. Is there a relatively painless way to do this? Many thanks.

Ed K
  • 1
  • 2

1 Answers1

1

Below code will copy name of all files from **C:\testFolder** in column A.

Sub test()
    Dim file As Variant
    file = Dir("C:\testFolder\")
    Range("A2").Activate
    While (file <> "")
        ActiveCell.Value = file
        ActiveCell.Offset(1, 0).Activate
        file = Dir
    Wend
End Sub
Aditya Pansare
  • 1,112
  • 9
  • 14