Password protected VBA module problem

AmericanSeiko

New Member
Joined
Sep 16, 2013
Messages
21
Password protected VBA module causes Excel to crash on debugs. Macros work fine if I open VBE and enter my password.

I'm using Range.("This range does not exist").Select to force a debug.

If I run my macro without entering my module password, the debug window appears and Excel crashes.

If I run my macro after entering my module password, the VBE window opens and it debugs normally.

I'm 90% sure the password protection is the problem. I want to keep my code password protected, but I don't want my project to crash on an error. Any ideas on how to fix/workaround this?

Thanks everyone!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Your code is password protected, so the Debug window will work only if you enter the password.

The only solution is to gorilla proof your code, writing your own error handling to handle the errors that come up. Something like this perhaps.

Code:
Sub MySub()
    On Error Goto MyHandler
    ' some code
    Range.("This range does not exist").Select
    ' more code
    On Error Goto 0
    Exit Sub
MyHandler:
    MsgBox "Error: " & Err & vbcr & Error
End Sub
 
Upvote 0
MyHandler:
MsgBox "Error: " & Err & vbcr & Error

Thank you! That completely solved my problem. I've worked with custom error handlers before, but I don't know what " & Err & vbcr & Error" do. Would you care to enlighten me?

Thanks again for answering my question!
 
Upvote 0
Err and Error are system messages giving the number and text description of a VB error that occurs.

In the example given Err was 1004 and Error was "Method 'Range' of Object' _Global failed"
 
Upvote 0

Forum statistics

Threads
1,216,054
Messages
6,128,516
Members
449,456
Latest member
SammMcCandless

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