Forum Discussion
VBA Code stops
The code stops because an unhandled error occurs in one of the button‑click procedures after the SAP refresh. Because ScreenUpdating = False is active and you have no error handler, the error is silent and execution halts.
Try these steps in order:
1. Make errors visible – Add a basic error handler:
On Error GoTo EH
...
Exit Sub
EH:
Application.ScreenUpdating = True
MsgBox "Error: " & Err.DescriptionThis will reveal exactly which line fails and why.
2. If no error message appears but execution still stops, the fault is likely that a button subroutine is now Private or has been renamed/deleted. In the VBA editor, check that each called macro (Sheet14.CommandButton2_Click etc.) exists in the appropriate sheet module and is Public (or has no scope keyword).
3. If the error points to missing data, the SAP refresh may now finish asynchronously. Insert a short wait (Application.Wait Now + TimeValue("0:00:03")) or, if the add-in supports it, check api.IsRefreshRunning in a loop before continuing.
4. Confirm sheet code names – If a sheet was deleted and re‑added, its internal Sheet14 name may have changed. In the Project Explorer, verify the name in parentheses matches the SheetXX you are calling.
Start with the error handler – it will instantly pinpoint the breaking point.
My answers are voluntary and without guarantee!
Hope this will help you.