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.
Asked
Active
Viewed 126 times
1 Answers
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
-
Brilliant! Works perfectly. Thank you! – Ed K Oct 23 '16 at 08:41