Excel Reference

Refer to Cells by Using a Range Object

Direct Answer

Refer to Cells by Using a Range Object
is part of the Excel VBA object model. This reference page documents its syntax, parameters, and typical usage.

Reference

If you set an object variable to a Range object, you can easily manipulate the range by using the variable name.

The following procedure creates the object variable myRange and then assigns the variable to range A1:D5 on Sheet1 in the active workbook. Subsequent statements modify properties of the range by substituting the variable name for the Range object.

vb
Sub Random()
Dim myRange As Range
Set myRange = Worksheets("Sheet1").Range("A1:D5")
myRange.Formula = "=RAND()"
myRange.Font.Bold = True
End Sub

!include[Support and feedback]

Reference: Excel object-model documentation • updated 06/08/2017
. Rebuilt for readability; see the original for complete parameter matrices.