![]() |
Macro to Find File in Subfolders and Open it
Hi all, I am using excel 2007. In Folder "C:\My Document\Record" I
have many Subfolders and in all those subfolders I have many excel (xlsx) files. All the files names are like the given example below 523360.xlsx 563361.xlsx 658897.xlsx ……etc I want macro on a button and I want that when I put file name in cell A1 (for example like 523360) then macro should check that file in Folder "C:\My Document\Record" and also in all the subfolders of this Folder and when macro find that file then it should open it. But if macro dont find that file at all then it should pop up MsgBox that "File not Found". Please can any friend can help |
Macro to Find File in Subfolders and Open it
Maybe something here will give you some ideas:
http://www.rondebruin.nl/tips.htm Search for the files named 'Merge data from all workbooks in a folder...' There are at least three that may be of interest to you... Regards, Ryan--- -- RyGuy "K" wrote: Hi all, I am using excel 2007. In Folder "C:\My Document\Record" I have many Subfolders and in all those subfolders I have many excel (xlsx) files. All the files names are like the given example below 523360.xlsx 563361.xlsx 658897.xlsx €¦€¦etc I want macro on a button and I want that when I put file name in cell A1 (for example like 523360) then macro should check that file in Folder "C:\My Document\Record" and also in all the subfolders of this Folder and when macro find that file then it should open it. But if macro dont find that file at all then it should pop up MsgBox that "File not Found". Please can any friend can help |
Macro to Find File in Subfolders and Open it
For the OP
See the code here http://www.rondebruin.nl/fso.htm And you can change ExtStr to ExtStr:="523360.xlsx Or reference a cell value myCountOfFiles = Get_File_Names( _ MyPath:="C:\Users\Ron\test", _ Subfolders:=True, _ ExtStr:="*.xl*", _ myReturnedFiles:=myFiles) -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "ryguy7272" wrote in message ... Maybe something here will give you some ideas: http://www.rondebruin.nl/tips.htm Search for the files named 'Merge data from all workbooks in a folder...' There are at least three that may be of interest to you... Regards, Ryan--- -- RyGuy "K" wrote: Hi all, I am using excel 2007. In Folder "C:\My Document\Record" I have many Subfolders and in all those subfolders I have many excel (xlsx) files. All the files names are like the given example below 523360.xlsx 563361.xlsx 658897.xlsx €¦€¦etc I want macro on a button and I want that when I put file name in cell A1 (for example like 523360) then macro should check that file in Folder "C:\My Document\Record" and also in all the subfolders of this Folder and when macro find that file then it should open it. But if macro dont find that file at all then it should pop up MsgBox that "File not Found". Please can any friend can help |
All times are GMT +1. The time now is 08:36 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com