VBA: Run right through my Exit Sub

hellfire45

Active Member
Joined
Jun 7, 2014
Messages
462
Good day ladies and gentlemen:

So I've got an error handler in this subroutine. When the routine gets to the bottom, it "Calls" another routine, "datacompiler" to run. When this routine finishes, it is supposed to hit the "Exit Sub" and stop. However, instead of stopping, its running through down through my error handler, and closing the workbook.

Does anybody know why my routine is either jumping over, or running straight through my "Exit sub" line?
thank you so much!

(there is a lot of code above where the following code starts. I can post the rest if need be)

Code:
Workbooks(docname5).Close False

Call datacompiler

Exit Sub

'----------------------------------------------------ERROR HANDLERS------------------------------------------------------------------
SonGoku:
Application.DisplayAlerts = False
 MsgBox ("Worksheet(aka tab) Missing or wrong name")
 ActiveWorkbook.Close
  Exit Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Very likely the datacompiler subroutine has no internal error handler and is producing an error which is forcing the err handler from the main sub to skip you to the SonGoku line.

You can step through using F8 and see exactly where the error is occurring.
 
Upvote 0

Forum statistics

Threads
1,214,397
Messages
6,119,273
Members
448,883
Latest member
fyfe54

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