Show a list in Excel with all files in a specific folder

We’ve all been there.. You have a folder with 200 files in it (MP3 or whatever), and you want to have a list of those files in Excel.
Create a list with all files from a certain folder on your laptop or desktop.
Fast & simple, define the folder and the output location, and run..


Sub AllFilenames()
'Change D:\ to your folder path
D = "D:\"
'Change the output. First select a header location & name..
Cells(1, 1) = "Filenames"
'Choose a row to start the output..
r = 2
f = Dir(D, 7)
Do While f <> ""
'and choose a column for the output..
  Cells(r, 1) = f
  r = r + 1
  f = Dir
End Sub