Did I lose you? Can you see how this is so confusing? Again there's the Noun-dot-Something construct, but this time it is Object.Property rather than Object.Method. How do you tell them apart? Well, it is really subtle. There is no colon before the equal sign. A property is almost always being set equal to something, or perhaps the value of a property is being assigned to something else.

To make this cell color the same as Cell A1, you might say ActiveCell.Interior.Colorlndex = Range("A1").Interior.ColorIndex

Interior.Colorlndex is a property. By changing the value of a property, you can make things look different. It is kind of bizarre—change an adjective and you are actually doing something to the cell. Humans would say "Color the cell yellow." VBA would say:

ActiveCell.Interior.ColorIndex = 30

Table 2.1 summarizes the VBA "parts of speech."

0 0

Post a comment