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:
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?
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?