Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

macro query re open file with date

Posted on 2014-01-13
2
Medium Priority
?
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

618 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