Info

Collection

Plural Noun

Usually specifies which object: Worksheets(l)

Method

Verb

Object.Method

Parameter Adverb Lists parameters after the method. Separate the parameter name from its value with :=

Parameter Adverb Lists parameters after the method. Separate the parameter name from its value with :=

Property Adjective You can set a property activecell.height = 10 or query the value of a property x = activecell.height

Is VBA Really This Hard? No!

Knowing whether you are dealing with properties or methods will help you to set up the correct syntax for your code. Don't worry if it all seems confusing right now. When you are writing VBA code from scratch, it is tough to know whether the process of changing a cell to yellow requires a verb or simply an adjective. Is it a method or a property?

This is where the beauty of the macro recorder comes in. When you don't know how to code something, you record a short little macro, look at the recorded code, and figure out what is going on.

VBA Help Files—Using F1 to Find Anything

This is a radically cool feature, but I might make you jump through hoops first. If you are going to write VBA macros, you absolutely must have the VBA help installed. The problem: the VBA Help file is not installed in the default Office install. Here is how to see whether you have it.

1. Open Excel and switch to the VBA editor, using Alt+F11. From the menu, select Insert, Module (see Figure 2.1).

Figure 2.1

Insert a new module in the blank workbook.

Figure 2.1

Insert a new module in the blank workbook.

2. Type the three lines of code shown in Figure 2.2. Click inside the word MsgBox.

Figure 2.2

Click inside the word MsgBox and hit F1.

Figure 2.2

Click inside the word MsgBox and hit F1.

0 0

Post a comment