![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: Schiphol Airport, Netherlands
Posts: 48
|
We have to use data in a worksheet from an excel file that somebody else puts in a fixed directory on our network every day. Each day this source file has another name with the date included in the name. E.g. today's file would be called DRAAF20020426.xls and tomorrow's file would be called DRAAF20020427. The older files are not deleted.
Would it be possible to use VBA to automatically select the most recent file in this source directory and open it? Any help or suggestion or hopefully solution would be very much appreciated. |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
Tested this. Seems to work. The only thing you should need to do is add the correct path.
Tom [ This Message was edited by: TsTom on 2002-04-26 05:53 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: Schiphol Airport, Netherlands
Posts: 48
|
Thanks,
However it does not work completely correct. It does open a file, but not the most recent one. I noticed that in the code you compare datetwo with dateone. However, I find no place in the code were dateone is calculated. Could this be the problem? Tony |
|
|
|
|
|
#4 |
|
New Member
Join Date: Mar 2002
Location: Schiphol Airport, Netherlands
Posts: 48
|
Tom,
I found the problem. It has to to with date formatting. We use MM/DD/YYYY where you probably had MM/DD/YYYY. Now it works perfectly. Thanks a lot for the fast solution Tony |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|