Link to home
Start Free TrialLog in
Avatar of Justincut
Justincut

asked on

Add Previous Date to VBA Code

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
ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just the intrinsic Format function and the current date:

Filename = SelectMatchingWindow(Format(Date, "yy.mm.dd") &  "- Daily GMSP Balance Sheet.xlsm")
Avatar of Rob Henson
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