Copy folder file names into a sheet

Javier F Lopez

New Member
Joined
Jul 8, 2008
Messages
3
Hi Everybody... i need your help. I'm "new" at VBA... i have a folder with a lot of files in it and i need to copy their names into a excel spread sheet... i think i could do it using something like... for each file y folder xx, copy filename... =)

Could you please help me?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I have just done this for a client. Here is the code you need :-

Sub List_All_The_Files_Within_Path()
Dim Row_No As Integer
Dim No_Of_Files As Integer
Dim kk25 As Integer


Row_No = 6

With Application.FileSearch
.NewSearch
.LookIn = File_Path
.Filename = "*.*"
.SearchSubFolders = False
.Execute



No_Of_Files = .FoundFiles.Count


For kk25 = 1 To No_Of_Files
Worksheets("Check").Cells(kk25 + 5, 15).Value = .FoundFiles(kk25)

Next kk25


End With

End Sub

You need to change the woorksheet name from "Check" to whatever you have called it. Thanks

kaps
 
Upvote 0
Thanks a lot!!! You just saved me a lot of time!!
Also, i think i will get a smile from my coworkers!!!

Have a nice day!!
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top