How to use the ADDRESS function
The ADDRESS function returns the address of a specific cell, you need to provide a row and column number.
Table of Contents
- ADDRESS Function Syntax
- ADDRESS Function Arguments
- ADDRESS Function example
- ADDRESS function not working
- Get value based on row and column number
- Get value based on row and column number - ADDRESS function alternative
- Get value based on a row and column number and a worksheet name
- Create an address to a cell range and return values from that cell range
- Extract column letter - Excel 365
- Convert column number to column letter
- Convert column letter to column number
- Convert column number to column letter (VBA)
- Convert column letter to column number (VBA)
- Get Excel *.xlsx file
1. Excel Function Syntax
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
2. Arguments
row_num | Required. A number representing the row number. |
column_num | Required. A number representing the column number. |
[abs_num] | Optional. Lets you choose the type of reference to return. 1 - Absolute. 2 - Absolute row, relative column. 3 - Absolute column, relative row. 4 - Relative. |
[a1] | Optional. Lets you choose reference style. A1 reference style is the default setting you are probably used to. The R1C1 reference style has both columns and rows are labeled numerically. TRUE - A1-style reference. FALSE - R1C1-style reference. |
[sheet_text] | Optional. A text value that specifies the name of the worksheet to be used as the external reference. =ADDRESS(1,1,,,"Sheet2") returns Sheet2!$A$1. If omitted the function refers to a cell on the current sheet. |
3. ADDRESS Function example
Formula in cell D3:
The formula returns the address of a cell based on the row number in cell B3 and the column number in cell C3. The address is returned as an absolute reference in A1 style by default. For example, if B3 contains 1 and C3 contains 30, the formula returns $AD$1.
You can change the type of reference and the style of the address by adding optional arguments to the formula.
For example, =ADDRESS(B3, C3, 4) returns a relative reference (G5),
and =ADDRESS(B3, C3, 1, FALSE) returns an absolute reference in R1C1 style.
3.1 Explaining formula
Step 1 - ADDRESS Function
The ADDRESS function calculates the address of a specific cell based on a row and column number.
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
Step 2 - Populate arguments
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
row_num - B3
column_num - C3
[abs_num], - optional
[a1] - optional
[sheet_text]) - optional
Step 3 - Evaluate ADDRESS function
ADDRESS(1, 30)
and returns "$AD$1". This is a string, not a cell reference.
4. ADDRESS function not working
Make sure your spelling is correct, the image above shows a #NAME! error in cell D3. The ADDRESS function is misspelled.
The image above shows a #VALUE! error, the second argument expects a cell reference or a number, however, a text string is used.
5. Get value based on row and column number
Formula in cell D3:
The formula returns the value of the cell that has the address specified by the row number in cell B3 and the column number in cell C3. The ADDRESS function returns the address as a text string, and the INDIRECT function converts the text string into a valid reference. For example, if B3 contains 7 and C3 contains 3, the formula returns the value of cell C7.
You can use this formula to create a dynamic reference to a cell that changes based on the values in other cells.
5.1 Explaining formula
Step 1 - Calculate address
ADDRESS(B3, C3)
becomes
ADDRESS(7, 3)
and returns C7.
Step 2 - Convert string to cell reference
The INDIRECT function creates a cell reference from on a value.
INDIRECT(ref_text, [a1])
INDIRECT(ADDRESS(B3, C3))
becomes
INDIRECT("C7")
and returns "C".
6. Get value based on row and column number - ADDRESS function alternative
I recommend the INDEX function instead of the ADDRESS and INDIRECT function to create a cell reference that you will be using to get a value. As I mentioned above, the INDIRECT function is volatile and I recommend avoiding volatile functions as much as possible.
Formula in cell D3:
The formula returns the value at the intersection of the row and column specified by the values in cells B3 and C3. The INDEX function takes a range or array as the first argument, and a row number and a column number as the second and third arguments. For example, if B3 contains 7 and C3 contains 3, the formula returns the value in cell C3. You can use this formula to look up values from a table or array based on numeric positions.
6.1 Explaining formula
Step 1 - INDEX function
The INDEX function returns
INDEX(reference, [row_num], [column_num], [area_num])
reference -
row_num -
column_num -
area_num -
Step 2 - Populate arguments
INDEX(reference, [row_num], [column_num], [area_num])
reference - A1:E11
row_num - B3
column_num - C3
area_num - optional
Step 3 - Evaluate INDEx function
INDEX(A1:E11,B3,C3)
becomes
INDEX(A1:E11,7,3)
becomes cell reference C7
and returns "C".
7. Get value based on a row and column number and a worksheet name
The image above demonstrates a formula in cell D3 that returns a value from another sheet using the ADDRESS function.
Formula in cell D3:
The formula above calculates the value of the cell that has the address specified by the row number in cell B3 and the column number in cell C3 on the worksheet named “ADDRESS function”. The ADDRESS function returns the address as an absolute reference in A1 style by default. The INDIRECT function converts the text string into a valid reference. For example, if B3 contains 3 and C3 contains 2, the formula returns the value of cell $B$3 on the worksheet “ADDRESS function”.
7.1 Explaining formula
Step 1 - ADDRESS function
The ADDRESS function calculates the address of a specific cell based on a row and column number.
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
Step 2 - Populate arguments
row_num - B3
column_num - C3
[abs_num], - optional
[a1] - optional
[sheet_text]) - "ADDRESS function"
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
becomes
ADDRESS(B3, C3, , , "ADDRESS function")
and returns 'ADDRESS function'!$B$3.
Step 3 - Create cell reference
The INDIRECT function creates a cell reference from on a value.
INDIRECT(ref_text, [a1])
INDIRECT(ADDRESS(B3, C3, , , "ADDRESS function"))
becomes
INDIRECT('ADDRESS function'!$B$3)
and returns 1.
8. Create an address to a cell range and return values from that cell range
The image above shows a formula in cell E3 that creates a cell reference to a cell range using the ADDRESS function.
Array formula in cell E3:
The formula above calculates a reference to the range of cells that has the address specified by the row and column numbers in cells B3, C3, B4 and C4. The ADDRESS function returns the address as a text string, and the & operator concatenates the two addresses with a colon (:) to create a range reference. The INDIRECT function converts the text string into a valid reference.
For example, if B3 contains 8, C3 contains 2, B4 contains 9 and C4 contains 3, the formula returns a reference to the range $B$8:$C$9.
8.1 Explaining formula
Step 1 - Top left cell
ADDRESS(B3,C3)
becomes
ADDRESS(8,2)
and returns string "B8".
Step 2 - Bottom right cell
ADDRESS(B4,C4)
becomes
ADDRESS(9,3)
and returns string "C9".
Step 3 - Create a cell address to a cell range
The ampersand character lets you concatenate text strings in an Excel formula.
ADDRESS(B3,C3)&":"&ADDRESS(B4,C4)
becomes
B8&":"&C9
and returns the string "B8:C9".
Step 4 - Create a cell reference
The INDIRECT function creates a cell reference from on a value.
INDIRECT(ref_text, [a1])
INDIRECT(ADDRESS(B3,C3)&":"&ADDRESS(B4,C4))
becomes
INDIRECT("B8:C9")
and returns cell reference B8:C9.
9. Extract column letter - Excel 365
The image above shows a formula in cell B3 that extracts the column letters from a given cell reference, in this example BC465.
Excel 365 formula in cell B3:
The formula calculates the column letters only from a given cell reference.
Explaining formula
Step 1 - Get column number
The COLUMN function returns a number representing the column of a given cell reference counting from the left.
COLUMN(cell_ref)
COLUMN(BC465)
returns 55. Column BC465 is the 55th column counting from the left, see the image above.
Step 2 - Create cell address
ADDRESS(1,COLUMN(BC465),4)
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
[abs_num] - Optional. Let's you choose the type of reference to return.
1 - Absolute.
2 - Absolute row, relative column.
3 - Absolute column, relative row.
4 - Relative.
ADDRESS(1,COLUMN(BC465),4)
becomes
ADDRESS(1,55,4)
and returns BC1.
Step 3 - Count characters
The LEN function returns a number representing the total amount of characters in a string.
LEN(str)
LEN(ADDRESS(1,COLUMN(BC465),4))-1
becomes
LEN("BC1")-1
becomes
3 - 1 equals 2.
Step 4 - Remove row number
The LEFT function extracts a specific number of characters always starting from the left.
LEFT(ADDRESS(1,COLUMN(BC465),4),LEN(ADDRESS(1,COLUMN(BC465),4))-1)
becomes
LEFT("BC1",2)
and returns "BC".
Step 5 - Shorten formula
The LET function lets you name intermediate calculation results which can shorten formulas considerably and improve performance.
LEFT(ADDRESS(1,COLUMN(BC465),4),LEN(ADDRESS(1,COLUMN(BC465),4))-1)
ADDRESS(1, COLUMN(BC465), 4) is repeated twice in the formula.
x - ADDRESS(1, COLUMN(BC465), 4)
LET(x, ADDRESS(1, COLUMN(BC465), 4), LEFT(x, LEN(x)-1))
10. Convert column number to column letter
Use the following formula to convert a column number to a column letter:
The formula is entered in cell D3 shown in the image above, the column number is in cell B3.
Explaining formula in cell D3
You can follow along if you start the "Evaluate Formula" tool. You will find it on tab "Formula" on the ribbon.
Press with left mouse button on "Evaluate" button to move to the next calculation step.
Step 1 - Create a relative cell reference based on row and column number
The ADDRESS function returns a cell reference depending on what you use in the first (row) and second (column) argument.
The third argument lets you choose the type of cell reference the ADDRESS function returns. 4 is a relative cell reference.
ADDRESS(1, B3, 4)
becomes
ADDRESS(1, 1, 4)
and returns A1.
Step 2 - Remove last characters based on column number
The column letters start with A and ends with XFD. A is column 1, AA is column 27, the first column reference that contains two letters.
AAA is the first column containing 3 letters and the corresponding column number is 703.
The MATCH function returns the position in the array of the largest value that is smaller than the lookup value (B3).
MATCH(B3, {1; 27; 703})
becomes
MATCH(1, {1; 27; 703})
and returns 1. The cell reference must have a single column letter.
Step 3 - Extract a given number of characters from the start of the string
LEFT(ADDRESS(1, B3, 4), MATCH(B3, {1; 27; 703}))
becomes
LEFT("A1", 1)
and returns A in cell D3.
11. Convert column letter to column number
The following formula converts a column letter to the corresponding column number.
Formula in cell C3:
If you don't want to use the INDIRECT function because it is volatile and may cause your worksheet to slow down considerably if used extensively, use this array formula.
If you rather use a regular formula, try this:
Explaining formula in cell C3
Step 1 - Create a cell reference from a text string
The ampersand character & concatenates the value in cell B3 with 1.
The INDIRECT function converts the text string to a cell reference.
INDIRECT(B3&"1")
becomes
INDIRECT("A"&"1")
becomes
INDIRECT("A1")
and returns A1.
Step 2 - Return column from cell reference
COLUMN(INDIRECT(B3&"1"))
becomes
COLUMN(A1)
and returns 1 in cell C3.
12. Convert column number to column letter (VBA)
User defined function in cell C3:
VBA code
Function ColumnLetter(col As Integer) As String ColumnLetter = Split(Cells(1, col).Address, "$")(1) End Function
Where to copy the code?
- Copy above custom function
- Go to VBA Editor (Alt+F11)
- Press with left mouse button on "Insert" on the top menu
- Press with left mouse button on "Module" to insert a module to your workbook
- Paste code into the code window
- Exit VBA Editor and return to Excel (Alt+Q)
Save your workbook
To be able to use the user defined function next time you open your workbook you need to save the workbook as a macro-enabled workbook.
- Press with left mouse button on "File" on the menu, or if you have an earlier version of Excel, press with left mouse button on the office button.
- Press with left mouse button on "Save As"
- Press with left mouse button on file extension drop-down list
- Change the file extension to "Excel Macro-Enabled Workbook (*.xlsm)".
13. Convert column letter to column number (VBA)
User defined function in cell C3:
VBA code
Function ColumnNumber(col As String) As Long ColumnNumber = Columns(col).Column End Function
Get Excel *.xlsm file
Convert column number to column letter.xlsm
Useful resources
ADDRESS function - Microsoft
ADDRESS Function Examples - Contextures
'ADDRESS' function examples
Functions in 'Lookup and reference' category
The ADDRESS function function is one of 25 functions in the 'Lookup and reference' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form