How to Disable Debug in VBA in Excel

Microsoft Excel relies on the Visual Basic language for some of its advanced features, including macros. When a Visual Basic macro generates an error in Excel, it presents the user with an option to debug the underlying code. If selected, this option opens the macro code in a Visual Basic editing window. Disable the debug option to protect the underlying code in your Excel workbook macros.

Step 1

Go to File, Options and then Customize Ribbon. In the Customize the Ribbon (Main Tabs) window pane, check the Developer option. Excel will now display a ribbon tab named Developer.

Step 2

Return to the Excel workbook or worksheet. Click the Developer tab and then Visual Basic Editor button on the left of the main ribbon menu.

Step 3

In the Visual Basic editor window, click Tools then VBAProject Properties.

Step 4

Click the Protection tab. Click to place a check next to Lock project for viewing. Enter a password in the applicable field, then type the password again in the confirmation field. Click the OK button.

Step 5

Save the workbook, then close and reopen it for the changes to take effect.

Tip

While this method protects the code in the case of an unexpected error, it is considered good programming practice to write code specifically to handle errors.

references