Ora

How do you get the column address in Google Sheets?

Published in Google Sheets Formulas 5 mins read

To get the column address in Google Sheets, you can use built-in functions like ADDRESS to obtain a full cell reference, or combine functions such as COLUMN and SUBSTITUTE to extract just the column letter.

Method 1: Getting a Full Cell Address with the ADDRESS Function

The ADDRESS function is a powerful tool in Google Sheets that generates a cell's address as text, based on specified row and column numbers. This address inherently includes the column letter you're looking for.

Syntax: =ADDRESS(row, column, [abs_num], [a1_notation], [sheet])

  • row: The row number of the cell.
  • column: The column number of the cell.
  • abs_num (Optional): Specifies whether the address is absolute (e.g., "$A$1") or relative (e.g., "A1").
    • 1 or omitted: Absolute ($A$1)
    • 2: Absolute row, relative column (A$1)
    • 3: Relative row, absolute column ($A1)
    • 4: Relative (A1)
  • a1_notation (Optional): A boolean indicating whether to use A1 notation (true) or R1C1 notation (false). Defaults to TRUE.
  • sheet (Optional): The name of the sheet to include in the address.

Example:
For instance, if you wanted the address of the cell in the second row and second column, you would use:
=ADDRESS(2, 2)

This formula precisely returns "B2", clearly indicating the column address 'B' within the full cell reference. This is particularly useful when you know the row and column numbers and need the standard A1-style reference.

Method 2: Extracting Just the Column Letter

If you need only the alphabetical letter of a column (e.g., "A", "B", "AA"), you can combine several functions.

2.1 From a Column Number

You can convert a column number into its corresponding letter using a combination of ADDRESS and SUBSTITUTE.

Formula: =SUBSTITUTE(ADDRESS(1, column_number, 4), "1", "")

  • column_number: The numerical index of the column (e.g., 1 for A, 2 for B).
  • ADDRESS(1, column_number, 4): This generates a relative cell address for the first row of the specified column (e.g., ADDRESS(1, 2, 4) returns "B1").
  • SUBSTITUTE(..., "1", ""): This removes the "1" from the generated address, leaving only the column letter.

Example:
To get the letter for the 3rd column:
=SUBSTITUTE(ADDRESS(1, 3, 4), "1", "") returns "C"

2.2 From a Cell Reference

If you have a cell reference (e.g., A1, C5), you can first get its column number using COLUMN and then apply the method above, or use REGEXEXTRACT for a more direct approach.

a) Using COLUMN with ADDRESS and SUBSTITUTE

Formula: =SUBSTITUTE(ADDRESS(1, COLUMN(cell_reference), 4), "1", "")

  • COLUMN(cell_reference): This function returns the numerical index of the column for the given cell (e.g., COLUMN(A1) returns 1, COLUMN(C5) returns 3).

Example:
To get the column letter for cell E10:
=SUBSTITUTE(ADDRESS(1, COLUMN(E10), 4), "1", "") returns "E"

b) Using CELL and REGEXEXTRACT

For a specific cell, you can also extract the column letter using CELL("address", cell_reference) combined with REGEXEXTRACT.

Formula: =REGEXEXTRACT(CELL("address", cell_reference), "[A-Z]+")

  • CELL("address", cell_reference): This returns the absolute address of the cell (e.g., CELL("address", A1) returns "$A$1").
  • REGEXEXTRACT(..., "[A-Z]+"): This extracts one or more consecutive uppercase letters from the string, which will be your column letter.

Example:
To get the column letter for cell G7:
=REGEXEXTRACT(CELL("address", G7), "[A-Z]+") returns "G"

Understanding Key Functions

Function Description Example Output
ADDRESS(row, column, ...) Returns a cell reference as a string, constructed from specified row and column numbers. This is useful for building dynamic cell references. Learn more about ADDRESS. =ADDRESS(2, 2) "B2"
COLUMN(cell_reference) Returns the column number of a specified cell or the column number of the cell where the formula is entered if no reference is provided. Learn more about COLUMN. =COLUMN(D5) 4
CELL("address", cell_reference) Returns information about the given cell, including its address. Learn more about CELL. =CELL("address", B3) "$B$3"
SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence]) Replaces existing text with new text in a string. Crucial for stripping the row number from an address to isolate the column letter. Learn more about SUBSTITUTE. =SUBSTITUTE("B1", "1", "") "B"
REGEXEXTRACT(text, regular_expression) Extracts matching substrings according to a regular expression. Useful for isolating specific patterns like column letters from a string. Learn more about REGEXEXTRACT. =REGEXEXTRACT("$A$1", "[A-Z]+") "A"

Practical Insights and Use Cases

  • Dynamic References: When working with scripts or complex formulas where column numbers are calculated, using ADDRESS helps convert these numbers into readable A1-style references.
  • Conditional Formatting: You can use these functions within conditional formatting rules to apply formatting based on column properties.
  • Data Validation: Create custom data validation rules that check if an entry matches a specific column.
  • Scripting: Understanding how to programmatically get column addresses is fundamental for Google Apps Script development, allowing you to manipulate spreadsheet data effectively.

By mastering these functions, you can precisely control and reference columns in your Google Sheets, making your spreadsheets more dynamic and powerful.