更新时间:2023-11-25 15:24:28
Sub test()
Dim WbookCheck As Workbook
On Error Resume Next
Set WbookCheck = Workbooks("Weekly Report.xls")
On Error GoTo 0
If WbookCheck Is Nothing then 'not open....
filepaths = "c:\clients\work\Weekly Report.xls"
If Dir(filepaths) = "" Then
MsgBox "Please save the latest file under the name" & _
" 'US Sector Flow Weekly Report' and run the macro again"
Exit Sub
Else
'file exists - open it
Set WbookCheck = Workbooks.Open(filepaths)
End If
End If
with WbookCheck
.Activate
.Sheets("This week").Copy _
Before:=Workbooks("Consolidated.xls").Sheets(1)
end with
End Sub