All,
When I run the code below, it opens yesterday's DOR (DO Report 10-18-23). It works perfectly. What I'm looking to do is when that code is run and yesterdays' DOR opens I want it to copy N5 thru O41 and then I need to paste that into the workbook I'm working on which is different every day, it will already be open it's name will be "10-18-23". When I do this tomorrow the workbook I will be working from will be "10-19-23"......and so on. I need it to be pasted on the "Sheet1" tab D11 thru E47
All the codes are run from from the sheet with with yesterday's date "10-18-23". This is because I use a template that is read only and they have to do a "save as" and that how the sheet gets it's name...(10-18-23) and so on.
Any help would be much appreciated. Thank You.
When I run the code below, it opens yesterday's DOR (DO Report 10-18-23). It works perfectly. What I'm looking to do is when that code is run and yesterdays' DOR opens I want it to copy N5 thru O41 and then I need to paste that into the workbook I'm working on which is different every day, it will already be open it's name will be "10-18-23". When I do this tomorrow the workbook I will be working from will be "10-19-23"......and so on. I need it to be pasted on the "Sheet1" tab D11 thru E47
All the codes are run from from the sheet with with yesterday's date "10-18-23". This is because I use a template that is read only and they have to do a "save as" and that how the sheet gets it's name...(10-18-23) and so on.
Any help would be much appreciated. Thank You.
VBA Code:
Sub OpenDOR()
Dim wbMyWorkbook As Workbook
Dim strWBName As String, strWBPathStub As String
Dim strWBPath As String, FullName As String
Dim i As Long
strWBName = "DO Report " & Format(DateAdd("d", -1, Date), "mm-dd-yy") & ".xlsm" 'yesterday's DO report
strWBPathStub = "https://ustsa.sharepoint.com/sites/Airport-R1-MHT/soc/SOC Scheduling/Shared Documents/DOR"
Application.DisplayAlerts = False
On Error Resume Next
For i = 1 To 3
strWBPath = Choose(i, strWBPathStub, _
strWBPathStub & "/" & Format(DateAdd("d", -1, Date), "yyyy.mm"), _
strWBPathStub & "/Archived/")
FullName = strWBPath & "\" & strWBName
Set wbMyWorkbook = Workbooks.Open(FullName, 0, False)
If Not wbMyWorkbook Is Nothing Then GoTo exitsub
Next i
MsgBox "Failed To Locate " & strWBName, 48, "Not Found"
exitsub:
Application.DisplayAlerts = True
On Error GoTo 0
End Sub