Ranges

A range is a contiguous, rectangular block of cells that has been referenced as a group in a cell formula or selected to be affected by some editing action, such as Copy Formulas or Move.

Creating a Range Object

A range object can either be initialized as an empty range, initialized with another range, or specified by coordinates. These examples show some alternatives for creating a range object.

 

CGXRange range; // empty range

CGXRange range2(range); // assign another range to range2

CGXRange range(1,1,4,4); // range (1,1) to (4,4)

CGXRange range(1,4); // range (1,4) to (1,4)

Named Ranges

Individual cells and cell ranges may be referred to by their standard address coordinates (A5..D25, for example) or by pre-assigned names. The Named Range option lets you assign a name to any cell or cell range.

A named range is a range of cells to which a name has been assigned with the Named Range utility. A named cell is a cell to which a name has been assigned. Both named ranges and named cells can be referenced by their names or by their addresses.

Using names can help clarify the logic of your spreadsheet, making it easier to share among users, and easier to update long after it was originally designed. Once defined, names can be used anywhere standard cell or range references are used, including in cell formulas.

The following guidelines apply to named ranges:

  • Objective Grid does not differentiate between uppercase and lowercase letters in range names. For example, Objective Grid would consider "Range1" and "range1" to be the same name.
  • Names must begin with an uppercase or lowercase alphabetic character. The rest of the name may include any combination of alphabetic characters, numeric characters, and the following characters: $, ., or _.
  • When an area containing a named range or cell is moved, Objective Grid automatically updates the definition of the name to reflect the new location.
  • Named cells and ranges can have relative or absolute addresses. When cells containing references to named cells with absolute addresses are moved, the references are not updated.
  • When cells containing a reference to a named cell or range are copied, Objective Grid converts the reference to an appropriately translated standard reference.
  • If you redefine a name, all instances of that name in the spreadsheet are updated as soon as the spreadsheet is recalculated.
  • If you remove a name definition, all references to that name in the spreadsheet are converted to appropriate standard references.
  • To name a cell or range call the SetRangeName() command:
  • Example:

     

    SetRangeName(_T("number"), CGXRange(6,1,10,4));