Excel Formula to Extract Uppercase Characters From a Text String

📅 Jan 11, 2026 📝 Sarah Miller

Isolating uppercase characters from complex alphanumeric strings in Excel is a notoriously tedious task, often frustrating data analysts charged with manual database cleanup. While standard text functions like LEFT or MID work well for fixed-width patterns, they fail when capital letters are scattered unpredictably throughout a cell.

Leveraging modern array formulas grants users instant, dynamic extraction without relying on complex VBA. Stipulation: This elegant solution requires Excel 365 or Excel 2021 to support dynamic array behavior. For example, extracting "API" from "Application Programming Interface (API)" is now entirely automated.

Below, we provide the exact formula architecture and a step-by-step guide to help you implement this solution in your spreadsheets.

Excel Formula to Extract Uppercase Characters From a Text String

In data management and analysis, you will frequently encounter messy, unstructured text strings in Excel. One common task is extracting specific elements from these strings, such as uppercase characters. Whether you are trying to extract initials from a name, isolate stock tickers, pull out acronyms (like NASA or IBM), or capture specialized product codes embedded within descriptions, isolating capital letters is a highly useful technique.

By default, Excel is notoriously case-insensitive. Standard lookup and text functions like FIND (which is case-sensitive) and SEARCH (which is not) can help locate characters, but extracting only uppercase characters across a text string requires more advanced formulas. This comprehensive guide covers multiple methods to achieve this, ranging from modern dynamic array formulas to classic legacy solutions, Power Query, and VBA.


Understanding the Logic Behind Case Detection in Excel

Before diving into the formulas, it helps to understand how Excel distinguishes between uppercase and lowercase letters. Excel provides two primary tools for this:

  • The EXACT Function: Compares two strings and returns TRUE only if they are identical, respecting case. For example, EXACT("A", "a") returns FALSE.
  • ASCII/ANSI Character Codes: Computers read characters as numeric codes. In the standard ANSI/ASCII character set, uppercase English letters (A-Z) correspond to numbers 65 through 90. Lowercase letters (a-z) correspond to numbers 97 through 122. We can leverage the CODE function in Excel to verify if a character falls within the 65-90 range.

Method 1: The Modern Excel 365 Solution (Best & Easiest)

If you are using Microsoft 365 or Excel 2021, you have access to dynamic arrays and helper functions like LET, SEQUENCE, and TEXTJOIN. These make extracting uppercase characters incredibly elegant and efficient without requiring programming or legacy keystrokes.

The Formula

=LET(
    text, A2,
    chars, MID(text, SEQUENCE(LEN(text)), 1),
    TEXTJOIN("", TRUE, IF((CODE(chars)>=65)*(CODE(chars)<=90), chars, ""))
)

How It Works

This formula leverages the LET function to define variables, making it easy to read and highly performant:

  1. text, A2: Assigns the cell containing your text to the variable text.
  2. chars, MID(text, SEQUENCE(LEN(text)), 1):
    • LEN(text) calculates the total length of the string.
    • SEQUENCE(...) generates an array of numbers from 1 to the length of the string. For example, if the text is "Excel VBA", it generates {1; 2; 3; 4; 5; 6; 7; 8; 9}.
    • MID extracts each character one by one, creating an array of individual characters: {"E"; "x"; "c"; "e"; "l"; " "; "V"; "B"; "A"}.
  3. CODE(chars): Converts each character in our array into its corresponding numeric character code.
  4. (CODE(chars)>=65)*(CODE(chars)<=90): This acts as a logical AND condition. It checks if the character code falls between 65 (A) and 90 (Z). The multiplication operator (*) returns 1 (TRUE) if both conditions are met, and 0 (FALSE) otherwise.
  5. IF(..., chars, ""): If a character is uppercase, it keeps the character; otherwise, it replaces it with an empty string ("").
  6. TEXTJOIN("", TRUE, ...): Joins all the filtered characters back together, ignoring empty values.

Method 2: The Legacy Excel Solution (Excel 2019 and Older)

If you are working on an older version of Excel that does not support SEQUENCE or LET, you can still extract uppercase letters using an array formula. This approach uses ROW and INDIRECT to construct the character sequence dynamically.

The Formula

=TEXTJOIN("", TRUE, IF(ISERR(CODE(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1))), "", IF((CODE(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1))>=65)*(CODE(MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1))<=90), MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1), "")))

Note: If you are using Excel 2016 or older, you must press Ctrl + Shift + Enter instead of just Enter to commit this as an array formula. If entered correctly, Excel will wrap the formula in curly braces { }.

Why ROW(INDIRECT(...)) is Used

In older Excel versions, ROW(INDIRECT("1:"&LEN(A2))) is the standard workaround to mimic the modern SEQUENCE function. If the cell A2 has 10 characters, INDIRECT("1:10") references rows 1 through 10, and ROW() converts that reference into an array of numbers: {1;2;3;4;5;6;7;8;9;10}.


Method 3: Power Query (The Scalable, No-Formula Approach)

For large datasets or recurring data import tasks, Power Query is an outstanding alternative. It does not require complex formulas and can clean thousands of rows instantly. Power Query uses a functional programming language called M, which has native case-sensitive text-handling functions.

Step-by-Step Instructions:

  1. Select your data range, navigate to the Data tab on the Ribbon, and click From Table/Range.
  2. In the Power Query Editor window, go to the Add Column tab and click on Custom Column.
  3. Name your new column (e.g., UppercaseExtract).
  4. In the custom column formula box, enter the following case-sensitive code:
    Text.Select([YourColumnName], {"A".."Z"})
    (Make sure to replace [YourColumnName] with the actual name of your column by double-clicking it from the list on the right).
  5. Click OK. You will immediately see a new column containing only the uppercase letters.
  6. Go to the Home tab and click Close & Load to return the extracted data back to an Excel worksheet.

Method 4: VBA User-Defined Function (UDF)

If you frequently need to extract uppercase letters and want a simple, custom function like =GetCaps(A2), writing a brief VBA macro is the ideal solution. It is clean, reusable, and easy to read.

The VBA Code

Function GetCaps(txt As String) As String
    Dim i As Long
    Dim charVal As Integer
    Dim result As String
    
    result = ""
    For i = 1 To Len(txt)
        charVal = Asc(Mid(txt, i, 1))
        ' Check if character code falls in A-Z range (65 to 90)
        If charVal >= 65 And charVal <= 90 Then
            result = result & Mid(txt, i, 1)
        End If
    Next i
    
    GetCaps = result
End Function

How to Install and Use the VBA Function:

  1. Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
  2. Click Insert > Module to create a new module sheet.
  3. Copy and paste the code above into the module.
  4. Close the VBA editor window.
  5. In your worksheet, use the function just like any regular Excel formula:
    =GetCaps(A2)

Remember to save your workbook as an Excel Macro-Enabled Workbook (.xlsm), otherwise, the VBA code will be lost when you close the file.


Comparative Summary: Which Method Should You Choose?

To help you decide which technique fits your workflow best, here is a quick comparison table:

Method Compatibility Speed & Performance Pros Cons
Excel 365 (LET/SEQUENCE) Excel 365 / 2021+ Fast Dynamic, no macro required, auto-calculates. Not supported in older Excel versions.
Legacy Array Formula Excel 2019 and older Medium Works on older machines without macros. Complex to write; requires CSE array entry.
Power Query Excel 2010 to present Very Fast (large data) No formulas, perfect for data cleaning pipelines. Does not update automatically (requires Refresh).
VBA Macro (UDF) All Excel Desktop versions Fast Simple worksheet formula syntax: `=GetCaps()`. Requires macro-enabled workbook (.xlsm) format.

Conclusion

Extracting uppercase characters from a mixed string in Excel may seem challenging initially because the program is built to ignore character cases by default. However, utilizing character codes (ASCII 65-90) makes the process straightforward. Whether you choose the cutting-edge dynamic arrays of Excel 365, the backward compatibility of array formulas, the powerful parsing engine of Power Query, or the simplicity of a VBA custom function, you now have the tools to handle mixed-case data streams easily.

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.