Range

This class represents a cell, a row, a column, or a collection of cells in the a sheet.

Properties

Application through getApplication

BackColor through getBackgroundColor and setBackgroundColor

Count through getCount

Column through getColumn

ColumnWidth through getColumnWidth and setColumnWidth

EndColumn through getEndColumn

EndRow through getEndRow

EntireColumn through getEntireColumn

EntireRow through getEntireRow

Font through getFont

Formula through getFormula and setFormula

FormulaHidden through isFormulaHidden and setFormulaHidden

HasFormula through hasFormula

Height through getHeight

Hidden through isHidden and setHidden

MergeCell through isMergeCell and setMergeCell

Name through getName

Protected through isProtected and setProtected

PrintHidden through isPrintHidden and setPrintHidden

Row through getRow

RowHeight through getRowHeight and setRowHeight

Sheet through getSheet

StartColumn through getStartColumn

StartRow through getStartRow

Text through getText and setText

Value through getValue and setValue

Width through getWidth

WrapText through isWrapText and setWrapText

Methods

autoFit

autoFormat

borders

cells

clear

columns

copy

cut

group

insertHyperLink

offset

paste

range

replace

resize

rows

Select

sort

subtotal

unGroup

Access
  • To access all the used range of a sheet. use the UsedRange property in the Sheet class.
  • To access the range of a cell in the a sheet, use the Cells method in the Sheet class.
  • To access the range of a column in the a sheet, use the Columns method in the Sheet class.
  • To access the range of a row in the a sheet, use the Rows method in the Sheet class.
  • To access the range of a cell by name, use the Range method in the Sheet class.
  • To access the entire row (or rows) that contain the specified range, use the EntireRow property in the Range class.
  • To access the entire column (or columns) that contain the specified range, use the EntireColumn property in the Range class.
  • To access the range of a cell in the a range, use the Cells method in the Range class.
  • To access the range of a column in the a range, use the Columns method in the Range class.
  • To access the range of a row in the a range, use the Rows method in the Range class.
  • To offset a range, use the Offset method in the Range class.
  • To access the range of a cell by name, use the Range method in the Range class.
  • To resize a range, use the Resize method in the Range class.

Usage

Range provides access to cells, columns, and rows, and methods to provide sort, group, and subtotal operations.

To change the style of the range use the Borders method and the BackColor and Font properties.

To set formula for cells, use the Formula property.

The value of a cell can be a string value or a double value. The property Text is used to set the string value for a cell. The property Value is used to set the double value for a cell. The value for the Text property and Value property can overwrite each other's value.
  • When you set the value for the Text property, the value of the Value property is the numeric conversion value of the Text property's value.
  • When you set the value for the Value property, the value of the Text property is the string conversion value of the Value property's value.
For example, if we set the Text property's value as Test, the Value property's value is 0; if we set the Value property's value as 26.7, the Text property's value is 26.7.
See examples

Example: Range