Microsoft Office Tutorials and References
In Depth Information
To limit access to the VBE, click Tools ➪ VBAProject
Properties, which calls the VBAProject - Project
Properties dialog box. Click to select the Protection
tab. Place a checkmark in the box next to Lock
Project for Viewing. Enter a password you will
remember, and confirm it as shown in Figure 4-11.
Click OK to exit the dialog box. For the locked
protection to take effect, you need to save the
workbook and close it. Now, each time the
workbook is reopened, the Visual Basic Editor will
require your password if you or anyone tries to
gain access to the VBE.
In this lesson, you practice placing a macro into a new module. You type a short macro into
Notepad. The idea is to start getting accustomed to writing VBA code, and also to practice copying
a macro from outside of Excel (such as from a newsgroup or website) and pasting it into a new
module in Excel.
Place a macro from an external application into a new Excel module. In this exercise, Windows
Notepad is being used as the external application. To open Notepad, click the Start button at the
lower left corner of your screen, and from the Start menu select Programs (in later versions of
Windows it may be All Programs) ➪ Accessories ➪ Notepad.
Open Notepad, and type these four statements just as you see them, which is a VBA macro
named Example :
Range(“A1”).Value = “Hello”
MsgBox “You just entered Hello in cell A1.”
Return to Notepad, select the Example macro you just composed, and press Ctrl+C.
Return to Excel and, from your worksheet, press Alt+F11. That will take you to the Visual
The left pane should be visible and titled Project - VBA Project. That is called the Project
Explorer. If it is not visible, press Ctrl+R to access it.