Solved

macro query re open file with date

Posted on 2014-01-13
2
191 Views
Last Modified: 2014-01-14
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
0
Comment
Question by:Jagwarman
2 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 39776844
Hi Jagwarman,

Change "lastWorkingDate" to "dt". Seems you have an old variable name in there.

Matt
0
 

Author Closing Comment

by:Jagwarman
ID: 39778846
thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now