ajAddress function
Description
The ajAddress function returns a cell reference or a range reference as text.
Some AlchemyJ Extended Functions (e.g. ajJSON) and some address fields 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 ajAddress 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
ajAddress(cell_reference, [return_as_range], [address_type])
Argument Name | Argument Type | Description |
---|---|---|
cell_reference (required) | Range | The cell or the range to return. Please note that if a range of cells is specified in ‘Cell_reference’, the only operation that applies to the whole row or column can be detected. For example, for range A1:B2, if you insert a cell in A2 by shifting the cell down to A3, the address reference in ajAddress will not be updated. |
return_as_range (optional) | Boolean | 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 the 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 The default value is FALSE. |
address_type (optional) | Double | 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. The default value is 0. |
The function will return:
1) Return Value: Address of the referenced cell
2) Return Type: Single Value
Example
The function returns the address of the referenced cell.
By using the ajAddress(), the address will be auto-updated when the address was changed. For example, insert cell at B1 with Shift Cells Right.
The output of ajAddress is updated to 'GetAddress!C1' automatically.
Click here to download the use case workbooks for further reference.
Error Scenarios
It will return #VALUE! when missing any required parameter or mismatch parameter type. Besides, system will raise error for below scenario(s).
Error Scenario |
---|
Address type is invalid, it can only be 0, 1, or 2. |
Cell reference is referring to the other workbook. |