VBA working but not in Step Through mode

Pumper

Board Regular
Joined
Sep 12, 2013
Messages
95
Office Version
  1. 2016
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.


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:
It shouldn't be. If that were the issue, it should affect the code regardless of how it's run. Then again, Excel is weird, so...
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi Alex & RoryA, the problem was not the code which makes me feel bad for you spending time on it. (Thanks for cleaning up the code Alex)

The issue was an add-in apparently getting involved as soon as the open file part was run, this add-in was disabled and now works in both F5 and F8 modes.

Thanks very much for taking the time to look and sincere apologies for what turned out to be a non event.
 
Upvote 0
Solution
Thanks for the feedback, I will add it to my list of questions to ask when troubleshooting in the future. ;)
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

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