Quickly Find All files within a folder and sub folder in Excel VBA - Code Included

preview_player
Показать описание
Grab the Free VBA Quick Reference Guide
In this video we use a nice little piece of code that will find all of the files within a folder and all of its subfolders.

A Subscriber requested this video as he was reminiscing of ages gone by when Excel 2003 had a file search function

NOTE: Since this is pulling all the folder and subfolders it could take a lot of time and return a bunch of files

CODE:
==============

Sub Find_Files()

Dim fldr As FileDialog
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
fldr.Show
f = fldr.SelectedItems(1)
f = f & "\"

ibox = InputBox("File Must Contain (Note * wildcards can be used)", , "*.xls*")
On Error GoTo ext


Sheets(1).Cells(1).Resize(UBound(sn) + 1) = Application.Transpose(sn)

ext:

End Sub
Рекомендации по теме
Комментарии
Автор

Thanks! I've been looking for this for a long time. Great coding there.

markarvin
Автор

thanks a lot dear, really very thank full for your kind WELDONE WORK THANKS A LOT FOR THIS BEAUTIFUL SESSION OF FILE SEARCHING

POMI_Singing_Guru
Автор

Amazingly fast code! Thanks!! subscribed

ismaelmunoz
Автор

Perfectly it would be if cmd may run hidden. Is it possible?
But this solution is just brilliant!
Great thanks, man! 🤗

Rice
Автор

Hi there, thanks very much for the informative video, this code is great!

I just wondered, is there any way for the macro to take the two variables (the folder path and the search query) from predefined cells on the spreadsheet rather than manually inputting each time?

This may be a very simple query but i am just getting started with this kind of thing. Thank you.

YesltsMeAgain
Автор

Hi,
I have a button called UpLoad on my webpage which ask to upload the .csv file.
I am able to click that button using VBA code and after clicking that button on webpage a popup appears similar to open dialog box which ask to upload a file for example say "Star.csv" but i want to insert the file name called "Star.csv" which is stored in my local directory automatically using VBA without user interaction.

Any help will be appreciated .
Thanks!

amitbodhwani
Автор

Hi, do you know how can i extract paths that contain tildes? or how can i treat them after i extract the paths?

Im using a code after finding all that paths that will open all the files one by one and extract data from each one of them.

Please let me know.

wuguerrero
Автор

Thanks for the video
I have the Question.
How to hide cmd windows on running in case many file? (Running in the background)

WKatekaew
Автор

This code is beautiful and very handy. I've been trying to alter it to make it so that rather than looking for just file extensions it can use approximate values to search. For example, say I want to find every file that contains the word "Bananas" it its file name. How would I go about that?

thomassutton
Автор

Thanks for the video. This is pretty close to what I am trying to accomplish. My dilema is that the files are contained on a web server. I want to list al .dat files within the directory. How can this be changed to search a web server location, instead of a network drive?

flcommentator
Автор

could you please explain the key code there? I can't figure out how it works. Thank you

popobolin
Автор

How can it write the list to a Access table?
Thanks

tommydieguez
Автор

Do you have an equivalent for the Mac Terminal?

LeeTownsend-rxsm
Автор

hi. this is a really awesome code. how do i modify this code to open every text file and search for a particular word or number that the user has entered. the output will be on a sheet before copying to a notepad and deleting the sheet or clearing it. i have been asking for help everywhere but no definite answer.

leehonghui
Автор

Great Coding reading comments, but I can't get it to work.. I have inserted code in module and hit run. I get he pop up boxes but nothing displays in Sheet 1 Column 1.. Can u please help

johnguo
Автор

great code. How to I modify it so it searches for a name in a column and puts the path to the file in the next column

manufacturersalesrepresent
Автор

Thanks for the code. I want to use it from office outlook. How in the vba code is the list of search results stored? I mean, what is the next step if I want to show all of the result files, but not in excel (directly in the filepath?) How can i show the result of sn in vba?

boeykensa
Автор

If I run this code AS IS, it is asking to "dimension" f, ibox & sn. Why these three variables are not defined here but still it works?

tymussh
Автор

It’s it possible to write the file paths to an Excel table (listobject) and can I also get the file names and date modified ?

DJPejsen
Автор

is there a way to run this code to list in a second column the date last modified information? Thank You!

htmwkof