Hello
I have found code to list and hyperlink all files within a directory but is there a way with VBA to search for files from a directory with 3 sub folders using an inputted cell value with a wildcard, then list the subfolder name as a hyperlink and with the files found?
For example the cell A1 could be inputted with 1234*, B2 would contain the directory path.
The found file names would then appear in column C and the containing folder name appear in column B as a hyperlink.
Hi Learning2
See if this is what you wanted.
Please do not key an asterisk (*) in cell A1. Just enter 1234 and it will search for all file names containing 1234.
Normally the file name is hyperlinked, not the folder's name. Anyway I hyperlinked both.
Cheers
Sunny
Hi Sunny
That is exactly what I was looking for 🙂
I have around 8000 files in one folder so it takes a while to process but does the job perfectly!
Thank you
Hi,
Not sure what your own code does but these may add something
https://www.myonlinetraininghub.com/create-hyperlinked-list-of-files-in-subfolders
https://www.myonlinetraininghub.com/create-hyperlinked-list-of-files-in-a-folder-using-vba
Regards
Phil
Hi Phil and thanks for responding,
I basically have a multitude of subfolders in a main folder and wished to find files in the subfolders that start *nnnn-nn* (n being a number) and what subfolder it is in with both the file and sub folder reported as hyperlinks.
Sunny' code uses the value from cell A1 instead of an input box and not too dissimilar in principle
Hyperlinked File List in Single Column works faster in comparison with Sunny' code but are similar in size in terms of coding?
Could you help me understand the difference to the hyperlinking and Sunny's coding - Hyperlinks.Add_Anchor:=ActiveSheet.Range("C" & xNextRow), _ Address:=xFile.Path, TextToDisplay:=xFile.Name so I can make the holding folder a hyperlink also.
Would be good if the subfolders (paths) that does not contain any *nnn-nn* files could be omitted in the result
Hi Learning2
You did ask that the macro to look into cell A1 so that's what I did.
For example the cell A1 could be inputted with 1234*, B2 would contain the directory path.
The found file names would then appear in column C and the containing folder name appear in column B as a hyperlink.
If speed is a concern, then Philips code will do, although I would prefer my file names to be in a single column so that I can sort them. Also DIR() cannot display Chinese characters while FSO can do that (and I need that).
Choose whichever that suit you.
Cheers
Sunny