Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I find a file/spreadsheet that Excel says is Already open but I can't find it? nwtrader8 Excel Discussion (Misc queries) 5 June 21st 05 02:16 PM
find from Excel VBA a text file last row 0000_AAAA_0000[_2_] Excel Programming 1 October 13th 04 08:43 PM
Excel VBA - open text file, replace text, save file? Cybert Excel Programming 2 October 2nd 04 01:05 AM
Doing a find and replace in a text file Nick Lancuba Excel Programming 2 June 23rd 04 02:24 AM
importing text file, removing data and outputting new text file Pal Excel Programming 8 February 27th 04 08:32 PM


All times are GMT +1. The time now is 02:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"