The Select Method presented here is an important method of the Range Object.
Sub SelectDemo() Range("A1:B3").Select End Sub
The Range.Select Method selects the cells in your range.
The Offset Property adjusts your position based on the initial Range you define.
Sub SelectDemo() Range("A1:B3") = 3 Range("A1:B3").Offset(1, 2).Select End Sub
The Offset Property accepts two arguments: a row and a column. In the example above, the range is offset by 1 row and 2 columns before being selected.
The Selection Property refers to the currently selected range or item and can be used to manipulate values. As a general rule of thumb, most things you can perform with the Range Object, you can also perform with Selection. Keep in mind that selecting cells individually in your VBA macros will slow your code down. I recommend using Application.ScreenUpdating=False if you’re selecting cells.
Sub SelectionDemo() Range("A1").Select Selection.Offset(1, 0).Select End Sub
Offsetting the currently selected cell by 1 row is quite useful inside long VBA loops. If you’re a loyal follower of my VBA Tutorials Blog, I’m sure you’ve seen me do this. The Selection property is rarely needed, but I’ll use it on occasion inside large loops since the Integer Data Type is limited to integers less than 32,767.
Sub SelectionDemo() Range("A1").Select Selection.Interior.Color = vbYellow End Sub
The Color Property, a property of the Interior Object, is used to change the cell color. Remember, you can use
Selection.Clear to clear the formatting.
In this lesson, you learned about the Select Method of the Range Object and about the Selection Property. You learned how to offset your current selection, which is useful inside long VBA loops, and you learned that Selection shares many Properties and Methods with the Range Object.