Skip to content

encodeRange

On this page

Encode a Range or pair of CellAddresses to an A1:B2 range string.

Can be called as:

  • encodeRange(range) with a Range object
  • encodeRange(start, end) with two CellAddress objects

If start and end are the same cell, returns a single cell reference (no colon).

encodeRange(cs: CellAddress | Range, ce?: CellAddress): string

Parameters

NameTypeRequiredDescription
csCellAddress | RangeYesA Range object, or the start CellAddress
ceCellAddressNoOptional end CellAddress (when cs is a CellAddress)

Returns

string

Range string in A1 notation (e.g. "A1:B2" or "A1")