Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Add Previous Date to  VBA Code

Posted on 2014-11-03
3
Medium Priority
?
286 Views
Last Modified: 2014-11-04
Hi Guys,


How do I add the Previous Business day to an Excel File name in a variable string?

eg. In this SelectMatchingWindow File name , I want it to pick up "YY.MM.DD - Daily GMSP Balance Sheet.xlsm"

Sub Macro6()


Filename = SelectMatchingWindow("- Daily GMSP Balance Sheet.xlsm")


  'Sheets("EMEA").Select
   'Windows("10.29.14 - Daily GMSP Balance Sheet.xlsm (sent).xlsx").Activate
    Sheets("EMEA").Select
    Range("A3:M63").Select
0
Comment
Question by:Justincut
[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
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 2000 total points
ID: 40420399
Use the workday function, e.g.
dim sFileName as string

sFileName=format(application.WorksheetFunction.workDay(now(),-1),"mm.dd.yy") & "- Daily GMSP Balance Sheet.xlsm"
Filename = SelectMatchingWindow(sFileName)

Open in new window

0
 
LVL 12

Expert Comment

by:jkaios
ID: 40420588
Just the intrinsic Format function and the current date:

Filename = SelectMatchingWindow(Format(Date, "yy.mm.dd") &  "- Daily GMSP Balance Sheet.xlsm")
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 40421388
Can I suggest you don't use fullstops within the file name? Some virus checkers will take this file as having multiple file extensions so could include a virus.

Thanks
Rob H
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

715 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