Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing most recent file

I need to import data (txt file) that changes often. Each time it changes
the name changes based on the time stamp. How can I import the most recent
filewith macro or VBA?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Importing most recent file


You will have to set up a filesystemobject to get the createdate from
the files in the specified directory.


--
bgeier
------------------------------------------------------------------------
bgeier's Profile: http://www.excelforum.com/member.php...o&userid=12822
View this thread: http://www.excelforum.com/showthread...hreadid=546110

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Importing most recent file

You can try something like this:

Dim dt as Date, dtMax as Date
Dim sPath as String, sName as String
Dim sMax as String, bk as Workbook
sPath = "C:\MyFiles\" '<= change to your directory
sName = dir(sPath & "*.txt")
dtMax = 0
sMax = ""
do while sName < ""
dt = fileDateTime(sPath & sName)
if dt dtMax then
sMax = sName
dtMax = dt
end if
Loop
set bk = Workbooks.Open(sPath & sMax)

--
Regards,
Tom Ogilvy


"wrcaz" wrote in message
...
I need to import data (txt file) that changes often. Each time it changes
the name changes based on the time stamp. How can I import the most

recent
filewith macro or VBA?



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 delete a file from recent documents file in excel exile New Users to Excel 1 March 7th 09 01:59 AM
Most recent file list Mikerosoft Excel Programming 1 December 21st 05 03:19 PM
Most Recent File problem - Help!! Wibs Excel Discussion (Misc queries) 1 November 20th 05 01:21 PM
~Recent File~ andibevan Excel Worksheet Functions 2 November 19th 04 08:52 PM
Locate Most Recent File andibevan Excel Programming 3 October 27th 04 12:13 PM


All times are GMT +1. The time now is 01:39 PM.

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"