ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open text file based on date. (https://www.excelbanter.com/excel-programming/374610-open-text-file-based-date.html)

Dan Jordan

Open text file based on date.
 
I am in need of a way to open a text file based on the
date in a worksheet.
I have many text files saved as ST20061007.txt , ST20061006.txt ect. all
files start with ST then the
date. I need to be able to open each file based on
a date inputted into another cell in the workbook,
So if a user enters 10/6/2006 then it would open
the file ST20061006.txt.

Any help would be Great.

Dan

*** Sent via Developersdex http://www.developersdex.com ***

Ron de Bruin

Open text file based on date.
 
Hi Dan

You can try this with the date in A1 it open the file that is in C:\

Workbooks.OpenText "C:\ST" & Format(Range("A1"), "yyyymmdd") & ".txt", Origin:=xlWindows

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Dan Jordan" wrote in message ...
I am in need of a way to open a text file based on the
date in a worksheet.
I have many text files saved as ST20061007.txt , ST20061006.txt ect. all
files start with ST then the
date. I need to be able to open each file based on
a date inputted into another cell in the workbook,
So if a user enters 10/6/2006 then it would open
the file ST20061006.txt.

Any help would be Great.

Dan

*** Sent via Developersdex http://www.developersdex.com ***




Dan Jordan

Open text file based on date.
 


Thanks Ron!! worked perfect

Dan

*** Sent via Developersdex http://www.developersdex.com ***


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com