Range Property

Microsoft Office Web Components Object Model

Show All

Range Property

       

Range property as it applies to the AutoFilter object.

Returns a Range object that represent the range of cells that the specified AutoFilter object applies to.

expression.Range

expression   Required. An expression that returns an AutoFilter object

 

Range property as it applies to the PivotData object.

Returns a PivotRange object that represents a cell or a range of cells.

expression.Range(TopLeft, BottomRight)

expression   An expression that returns a PivotData object.

TopLeft   Required PivotCell object. Specifies the upper-left cell in the specified range.

BottomRight   Required PivotCell object. Specifies the lower-right cell in the specified range.

 

Range property as it applies to the Range, Spreadsheet, and Worksheet objects.

Returns a Range object that represents a cell or rectangular range of cells. It is not possible to create a nonrectangular range or a range composed of discontiguous areas.

expression.Range(Cell1, Cell2)

expression   An expression that returns a Range, Spreadsheet, or Worksheet object.

Cell1   Required Variant. Specifies the entire range as an A1-style reference ("A1:C3", for example). The reference can include the range operator (a colon), the intersection operator (a space), or the union operator (a comma). It can also include dollar signs, but these are ignored. The reference can also specify the cell in the upper-left corner of the range as a Range object that contains a single cell, an entire column, or an entire row, or as a string that names a single cell. If Cell1 specifies the upper-left cell in the range, Cell2 is required.

Cell2   Optional Variant. (Required if Cell1 specifies the upper-left cell in the specified range.) Specifies the cell in the lower-right corner of the range. Can be a Range object that contains a single cell, an entire column, or an entire row, or it can be a string that names a single cell.

Remarks

When this property is applied to a Range object, the arguments specify cells relative to the range. The following example sets a variable to a Range object that represents cell B5.

Set tempRange = Spreadsheet1.Range("b5:b10").range("a1")

 

Example

This example sets the row height to 15 points for rows 1 through 10.

Spreadsheet1.Range("a1:a10").RowHeight = 15

This example sets a variable to a range that includes the second through last row of columns 3 and 4 in the current region for cell A1.

Sub GetRange()

   Dim rngCurRegion
   Dim rngTempRange

   Set rngCurRegion = Spreadsheet1.Range("a1").CurrentRegion

   Set rngTempRange = rngCurRegion.Range(rngCurRegion.Cells(2, 3), _
       curRegion.Cells(rngCurRegion.Rows.Count, 4))

End Sub