Hi All,
Strangely the VBA code runs correctly in normal mode for myself but errors for others and when I step through I get a "Can't execute in break mode error". (normally you get runs in step through mode an not normal mode with most errors was my understanding).
Have used debug.print and the correct spreadsheets are being referenced but seems to be an issue with this line, think the paste part has the issue?
Workbooks(xlFile).Worksheets("Capital").Range("A1:B300").Copy Workbooks(MyFile).Worksheets("Data").Range("A1")
Here is the code: any help would be greatly appreciated.
Strangely the VBA code runs correctly in normal mode for myself but errors for others and when I step through I get a "Can't execute in break mode error". (normally you get runs in step through mode an not normal mode with most errors was my understanding).
Have used debug.print and the correct spreadsheets are being referenced but seems to be an issue with this line, think the paste part has the issue?
Workbooks(xlFile).Worksheets("Capital").Range("A1:B300").Copy Workbooks(MyFile).Worksheets("Data").Range("A1")
Here is the code: any help would be greatly appreciated.
VBA Code:
Sub Totals()
Application.ScreenUpdating = False
Sheets("Data").Range("A1:B300").Clear
Const FILEPATH As String = "G:\Teams\Revenue\"
Const FILESPEC As String = "Management_*_@.xls"
Dim xlFile As String
xlFile = Dir(FILEPATH & Replace(FILESPEC, "@", Format(Date, "yyyymmdd")))
Application.Workbooks.Open Filename:=FILEPATH & xlFile
Dim MyFile As String
MyFile = Dir("G:\Teams\Revenue\Totals.xlsm")
Workbooks(xlFile).Worksheets("Capital").Range("A1:B300").Copy _
Workbooks(MyFile).Worksheets("Data").Range("A1")
Debug.Print xlFile
Debug.Print MyFile
Workbooks(xlFile).Close SaveChanges:=False
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: