"On Error Goto" not launching

lordterrin

Board Regular
Joined
Mar 21, 2012
Messages
155
Hi There,

I'm trying to make my workbook as easy to use as possible, so I'm including some error handlers, which up until now, have worked just fine.

I have the following code:

Code:
Sub GO()


Dim StepOne                 As Workbook
Dim StepTwo                 As String


Set DWMBook = ActiveWorkbook


ErrHandle:
Select Case Err
    Case 5:
    MsgBox "You've hit the 'go' button, but the worksheet you have listed in Step 1 is not open.  Please select an open workbook, and run this again."
    Exit Sub
End Select


DWMBook.Activate

On Error GoTo ErrHandle
Set StepOne = Workbooks(Sheets("Start").Range("B6").Value)
StepTwo = Sheets("Start").Range("B9").Value


StepOne.Activate
Application.Run StepTwo


End Sub

This code works perfectly. On the "macro book" that I've created, the user will select an OPEN workbook from a dropdown menu - and its name will be listed in range B6. They will then select a macro to run from another dropdown list, and the name of that macro will go into range B9.

I'm trying to add an error exception where in they select the name of an actual open workbook, but then CLOSE that workbook, and try to execute the macro. Instead of getting a run-time error 9, I'd like this to go over to the error handler, but it's not working.

Any idea why?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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