SpreadJS Documentation
INDIRECT
SpreadJS Documentation > Formula Reference > Formula Functions > INDIRECT

This function returns the reference specified by a text string.

Syntax

INDIRECT(Reftext,A1)

Arguments

This function has these arguments:

Argument Description
Reftext A reference to a cell that contains an A1 reference, an R1C1 reference, a name defined as a reference, or a text string reference to a cell. This argument is required.
A1 A logical value that specifies what type of reference is contained in the cell Reftext. This argument is optional.

Remarks

Use INDIRECT when you want to change the reference to a cell within a formula without changing the formula itself. Reftext is interpreted as an A1 reference if A1 is TRUE or omitted. Reftext is interpreted as an R1C1 reference if A1 is FALSE. If Reftext is not a valid cell reference, INDIRECT returns the #REF! error value. Changing a cell value causes the INDIRECT function and all dependent cells to recalculate.

Data Types

Accepts any data. Returns any data type.

Example

INDIRECT("A1")

INDIRECT(A1)

INDIRECT("R[-"&B1&"]C[-"&B2&"]", false)

Using Code

This example adds values to cells and uses the INDIRECT formula.

JavaScript
Copy Code
activeSheet.setValue(0,0,"b1");
activeSheet.setValue(1,0,"A")
activeSheet.setValue(2,0,"B")
activeSheet.setValue(0,1,2);
activeSheet.setValue(1,1,3);
activeSheet.setValue(2,1,1);
//activeSheet.getCell(1,3).formula("=INDIRECT(A1)");
//activeSheet.getCell(1,3).formula('=INDIRECT("A1")');
activeSheet.getCell(1,3).formula("=INDIRECT(A3&B2)");