Solved

macro query re open file with date

Posted on 2014-01-13
2
205 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
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 …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

920 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

16 Experts available now in Live!

Get 1:1 Help Now