[]
        
(Showing Draft Content)

INDIRECT

This function returns the reference specified by a text string.

Syntax

INDIRECT(ref_text, [a1_style])

Arguments

This function has these arguments:

Argument

Description

ref_text

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_style

(Optional) A logical value that specifies what type of reference is contained in the cell ref_text. 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. ref_text is interpreted as an A1 reference if A1 is TRUE or omitted.

ref_text is interpreted as an R1C1 reference if A1 is FALSE.

If ref_textt 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.

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)");