Ranges Collection Method: Add 

Purpose

Adds a new Range object to the collection.

Syntax

The Add method has the syntax:

Add(What, LowerBound, UpperBound, LeftBound, RightBound

Description

This method adds a new Range object to the collection and returns the newly added object.

The What parameter is optional, and can be either a Range object or omitted. In the former case, the Range object is appended to the Ranges collection. In the latter case, a new Range object is added.

The other parameters are also optional and provide the bounds of the range. If they are missing, the new Range object uses the table boundaries. It can be resized afterwards by accessing the properties of the Range object.

Dim oTable as Object

Dim oRange as Object

REM Different usages of the Add method

REM 1. Standard

Set oRange = oTable.Ranges.Add

REM oRange contains the whole table

REM 2. Create a Range which contains the Rows 2 to 10

Set oRange = oTable.Ranges.Add (, 2, 10)

Rem 3. Create a Range that contains the Columns 2 and 3

Set oRange = oTable.Ranges.Add (,,,2,3)

Rem 4. Build a Range collection, in that each Range has 5 Rows

Dim oRanges as Object

Set oRanges = oTable.BuildTiledRange(5)

Set oRange = oRanges.Item(3)