Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

Incorporate a folder picker in existing macro code

Dear Experts:

below macro, courtesy of an EE expert, lists all the paths of all files of a given directory in Column A of the current worksheet.

I  wonder whether somebody could help me to incorporate a folder picker in this code.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


Sub List_Path_Of_Files()
'List Files (entire path) from a given directory in Column A of current excel worksheet
'requires a folder picker to be perfect

Dim MyFolder As String
Dim MyFile As String
Dim a As Integer
MyFolder = "C:\Test\" ' <-- Change to your folder
MyFile = Dir(MyFolder & "*.*")
a = 0
Do While MyFile <> ""
    a = a + 1
    Cells(a, 1).Value = MyFolder & MyFile
    MyFile = Dir
Loop
MsgBox "Done. Column A lists all of the files of the given directory"
End Sub

Open in new window

0
AndreasHermle
Asked:
AndreasHermle
1 Solution
 
MacroShadowCommented:
Here you go.
EE.xlsm
0
 
AndreasHermleAuthor Commented:
Hi Macro Shadow,

I am very impressed. Thank you very much for your swift and professional help. Regards, Andreas
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now