![]() |
find a text in a file name
I need to loop throught n- number of files in a directory and if there is a
string "YTD" in the file name I had to put in cell B3 the string "YTD" and close it. Any help with the code will be appreciated Thanks Vlad |
find a text in a file name
sName = Dir("C:\Someplace\*.xls")
Do while sName < "" if instr(sName, "YTD") then workbooks.Open "C:\Someplace\" & sName worksheets(1).Range("B3").Value = "YTD" activeWorkbook.Close SaveChanges:=True end if sName = Dir() Loop -- Regards, Tom Ogilvy "vlad" wrote in message ... I need to loop throught n- number of files in a directory and if there is a string "YTD" in the file name I had to put in cell B3 the string "YTD" and close it. Any help with the code will be appreciated Thanks Vlad |
find a text in a file name
Tom,
Thanks for the help. As usual clean and right to the point. Thanks again "Tom Ogilvy" wrote: sName = Dir("C:\Someplace\*.xls") Do while sName < "" if instr(sName, "YTD") then workbooks.Open "C:\Someplace\" & sName worksheets(1).Range("B3").Value = "YTD" activeWorkbook.Close SaveChanges:=True end if sName = Dir() Loop -- Regards, Tom Ogilvy "vlad" wrote in message ... I need to loop throught n- number of files in a directory and if there is a string "YTD" in the file name I had to put in cell B3 the string "YTD" and close it. Any help with the code will be appreciated Thanks Vlad |
All times are GMT +1. The time now is 06:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com