ajGetAddress function
Description
The ajGetAddress function returns a cell reference or a range reference as text.
Some AlchemyJ Extended Functions (e.g ajMakeJson) and some address field in class template definition expect a cell address or range address in text format as their input. If a static reference such as A3 is keyed in, the setting will become incorrect when a new row has been added before row 3.
Inputting addresses using ajGetAddress can solve this problem. As the address becomes an input parameter of this function, Excel will automatically update the address when the cell is relocated.
Syntax
ajGetAddress(cell_reference, [return_as_range], [address_type])
Argument Name | Description |
---|---|
cell_reference (required) | Specify a single cell or range of cells and obtain the address of the single cell or range of cells. Please note that if a range of cells is specified in the ‘Cell_reference’, the only operation that applies to the whole row or column can be detected. For example, for the range A1:B2, if you insert a cell in A2 by shifting the cell down to A3, the address reference in ajGetAddress will not be updated. |
return_as_range (optional) | This is applicable if ‘Cell_reference’ is a single cell address. If it equals FALSE, a single cell address will be returned. If it equals TRUE, a single cell address in range format will be returned. For example, given Cell_reference is 'Business Logic'!A1 Setting ‘Return_as_range’ to TRUE will make it return 'Business Logic'!A1:A1 Setting ‘Return_as_range’ to FALSE will make it return 'Business Logic'!A1 If you do not specify anything, the default value will always be FALSE. |
address_type (optional) | 0 indicates returning the worksheet name and cell address. For example, Business Logic!A1. 1 indicates returning the cell address without the worksheet name. For example, A1. 2 indicates returning the worksheet name only. For example, Business Logic. If you do not specify anything, the default value will always be 0. |
The function will return:
1) Content type: Address of the reference cell
2) Method: Within a cell
Example
The function returns a range of sepecied cell(s). In this example, the address is 'GetAddress!B1'
By using the function, the address will be auto-updated when the address was changed. For example, insert cell at B1 with Shift Cells Right.
The output of ajGetAddress is updated to 'GetAddress!C1' automatically.