Help! Looking for a macro to open a file whose name changes every week

nlmtz80

New Member
Joined
Aug 9, 2018
Messages
2
Hi All,

I am trying to write a macro which opens a spreadsheet, whose name has a prefix which stays the same, but the date (mm.dd.yy) changes every week with the following format: ON_mm.dd.yy.xlsx

I.e This weeks name is 'ON_08.08.18.xlsx' and last weeks name is 'ON_08.01.18.xlsx'.

The report is created every Wednesday and refers to the previous weeks reports.

Thanks!:confused::confused::confused:
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
this works for me, adjust as needed:

place formula in cell A1 to get Wednesday date of the current week
Code:
=CONCATENATE("ON_",TEXT(TODAY()-WEEKDAY(TODAY(),3)+2,"mm.dd.yyyy"))

and macro
Code:
Sub OpenWB()
Dim WB2 As Workbook
Dim MyURL As String
Dim MyFile As String


    MyPath = "c:\testing\"
    MyURL = Range("A1").Value
    MyFile = MyPath & MyURL & ".xlsb"


    Set WB2 = Workbooks.Open(MyFile)


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,716
Messages
6,174,069
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top