Excel 2010 VBA Lesson 1: Introduction to Excel VBA Editor

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on Reddit

[Table of Contents]>>[Lesson 2]

Microsoft 2010 Excel  looks similar to Microsoft Excel 2007 but both are considerably different from Microsoft Excel 2003. MS Excel 2010 employs interactive ribbon controls for the menu bar instead of the old menu structure. Fortunately, the Visual Basic Editor (VBE) remains largely the same as that of version 2003. However, finding the active-x controls on the ribbon control is not as obvious as in Microsoft Excel 2003. You need to locate the Developer tab and click on it to launch the Excel 2010 VBA  project window, as shown in Figure 1.1.

vba2010_fig1.1

Figure 1.1



Sometimes the Developer tab is not shown on the menu bar. What should you do then? You have to open the Excel Options dialog by clicking File and then select options. The Excel Options dialog is as shown in Figure 1.2:

vba2010_fig1.2
Figure 1.2

In the Excel Options window, select customize ribbons and you can see the following dialog box, make sure you check the Developer option, as shown in Figure 1.3:

vba2010_fig1.3

Figure 1.3: Excel Options



After clicking on the Developer tab, you will be presented with the Developer window when you can have access to the  Excel 2010  VBA  editor  as well as recording macros and more, as shown below:

vba2010_fig1.4

Figure 1.4: The developer window

Clicking on View Code will launch the Excel 2010 VBA  Editor Code Window.

vba2010_fig1.5

Figure 1.5: The Excel 2010 VBA  Editor

Now select Sheet1 in the VBA objects explorer window on the far left and the Book1-Sheet1 windows appears. Enter the following statements in the sheet 1 code window:

Private Sub Worksheet_Activate()
 MsgBox "Welcome to Excel VBA 2010"
End Sub

As shown in Figure 1.6

vba2010_fig1.6

 

Whenever the user clicks on worksheet 1, the following message box will pop out:

vba2010_fig1.7



[Table of Contents]>>[Lesson 2]

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on Reddit