Avatar of Jagwarman
Jagwarman
 asked on

macro query re open file with date

can any Expert throw any light on this for me.

Have been using this code for a while and it's been fine but today its trying to open a file in a folder 1899 ???

Dim dt As Date
Dim wbk As Workbook
If Format(Now, "dddd") = "Monday" Then
lastWorkingDate = DateAdd("D", -3, Now())
   Else
    dt = DateAdd("d", -1, Now)
End If
Set wbk = Workbooks.Open("N:\EVERYONE\Ops to PC folders\" & Format(dt, "yyyy") & "\" & Format(dt, "MM MMM") & "\" & "Div rec " & Format(dt, "dd.MM.yyyy") & ".xlsx")

any ideas
Microsoft Excel

Avatar of undefined
Last Comment
Jagwarman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
mvidas

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jagwarman

ASKER
thanks
Your help has saved me hundreds of hours of internet surfing.
fblack61