Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working days: excluding weekends and holidays

Status
Not open for further replies.

peace77

Technical User
Jan 3, 2008
24
CA
Hello Friends,

I have another question on Excel VBA.

Our company saves file with certain information everyday in a standard format which contains the previous working date.

For example today (ie 11th March) a file is saved with name in this format- Capital_2008_03_10.txt

I have to develop a macro that automatically pulls the above file everyday and converts into excel. Is It possible to do so ?


Had it been today’s date I would have used this code:
Code:
Workbooks.OpenText FileName:= _
"\\C:\User_data\Files\Input_Files\Capital-" & Format(Now(), "yyyy-mm-dd") & ".txt", Origin:=437, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(5, 1), Array(11, 4), Array(21, 4), Array(32, 1), Array(35, 1), Array(51,1), Array(71, 1), Array(91, 1)), TrailingMinusNumbers:=True

I cant use Now()-1 because of weekends and holidays. Any ideas how I can automatically pull this file?

Thanks for the help.

Peace
 
You may use the Dir function and grab the latest C:\User_data\Files\Input_Files\Capital-????-??-??.txt file.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top