On May 16, 12:03 pm, tc wrote:
hi. i have a CSV file which i need to import on a regular basis. the
second half of the file name keeps changing eg. abcdXXXXXX where
xxxxxx is basically the date which keeps changing. can a macro be made
to automatically open this file and can this file name be split
inorder to use the date in the workbook for other purposes?
Just use a wildcard filespec ...
MyFileName = Dir("C:\Somefolder\abcd??????.ext")
if MyFileName = "" Then
msgbox "No file found" exit sub
else
' Parse filespec ...
sDatePart = Split(MyFileName, "\")
sDatePart = Right(Split(sDatePart(Ubound(sDatePart), ".")(0), 6)
'Open file and use the data ...
end if
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/