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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Business Day code VBA 3

Status
Not open for further replies.

Jimmylaki

Technical User
Jul 26, 2009
21
JP
Hello,

I need to modify my code which I use for opening a file for today -1 however, I need the file to select the last business day excluding WEEKENDS. I am using this as a sub
'TO OPEN THE FILE TO FILTER AND COPY

Dim yestdate As String
yestdate = Format(Date - 1, "ddmm") & ".xls"
Workbooks.Open Filename:="I:\Report\amendments" & yestdate

if someone could please help for a more useful code.

thanks JL
 



Hi,

Use a loop, subtracting days until you have a date that works. Of course, trap the errors.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
SkipVaught and joelflorendo have provided fine solutions. Which to use depends on whether you want the last file regardless of date, or want a file only if it is found with the last business-day date.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top