How to disable the excel visual basic debug

Updated July 20, 2017

Microsoft Excel relies on the Visual Basic language for some of its advanced features, including the use of 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. You may find this undesirable, especially in situations where the current user is not the macro's creator. Disabling the Debug option and thus protecting the underlying code is possible.

Click "Tools," "Macro" and then "Visual Basic Editor."

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

Click the "Protection" tab.

Click to place a check next to "Lock project for viewing." Enter a password in the "Password" field, then type the password again in the "Confirm Password" field.

Click "OK."

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


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.

Cite this Article A tool to create a citation to reference this article Cite this Article

About the Author

Marcie Thomas has a Master of Education in instructional technology. She specializes in the use of technology in higher education, including online learning. Thomas has experience with instructional design, Web development, network administration, PC support and technical writing.