Remove Letters from Numbers in Excel: Quick Formula Guide
Removing letters from numbers in Excel is a common data cleaning task that analysts, accountants, and marketers face regularly. When you import data from external sources, numerical fields often contain unwanted text characters, such as unit labels like "kg" or "ft," prefixes like "ID-" or "Product #," or trailing survey notes. Excel provides several robust methods to strip these letters away, leaving only the essential numeric values for calculation and reporting. Understanding these techniques ensures your datasets are accurate and ready for analysis.
Understanding the Problem: Why Letters Appear in Numbers
The core challenge lies in Excel's data type recognition. A cell formatted as "Text" will display "100 kg" exactly as typed, while a cell formatted as "General" might convert "100kg" into the number 100, ignoring the letters. However, when letters and numbers are concatenated within a single string, Excel treats the entire entry as text, preventing direct mathematical operations. The goal of extraction is to isolate the numeric portion, whether it sits at the start, middle, or end of the string, using pattern-based text functions.
Method 1: Using SUBSTITUTE for Known Characters
The simplest approach is the SUBSTITUTE function, which works best when you know the specific letters you want to remove. This method is ideal for removing units or static prefixes. For example, if a cell contains "Revenue (USD)" and you want just the number, you can nest SUBSTITUTE functions to strip out the parentheses and text. While powerful for targeted cleaning, this method becomes cumbersome if the variations are numerous or unpredictable, as it requires a separate function for each distinct character or string.
Method 2: Extracting Numbers with TEXTJOIN and FILTERXML
For a more dynamic solution that pulls out all digits regardless of their position, you can combine TEXTJOIN and FILTERXML. This technique treats the text string as an XML structure, filtering out only the numeric characters (0-9) from the sequence. The formula scans every character, identifies if it is a digit, and then concatenates them back into a clean number. This method is highly flexible and handles messy, unstructured data well, though it requires precise syntax to avoid errors in older Excel versions.
Advanced Extraction Techniques
When dealing with complex strings, legacy Excel functions like LEFT, RIGHT, and MID become essential. These functions allow you to extract characters based on their position. Often, you combine them with FIND or SEARCH to locate the starting point of the numbers. For instance, if you know the number always appears before a specific delimiter like a space or a hyphen, you can use FIND to get that location and then extract the substring. This precision is vital for standardizing entries like order codes or serial numbers.
Utilizing Flash Fill for One-Time Cleanses
Excel’s Flash Fill feature offers a visual, mouse-driven alternative to complex formulas. By typing the desired result in an adjacent cell and pressing Ctrl+E, Excel detects the pattern and fills the rest of the column automatically. This method is incredibly fast for one-time data cleanup jobs involving consistent patterns. However, it lacks the auditability of formulas—if source data changes, Flash Fill does not auto-update, making it less suitable for dynamic datasets that require regular refreshing.
Ensuring Results are Numeric
After successfully removing letters, you must verify the output is recognized as a number, not text. Results left-aligned in a cell indicate text formatting, which will cause errors in SUM or AVERAGE functions. To convert the cleaned text to a numeric value, multiply the result by 1, add 0, or use the VALUE function. This final step locks in the integrity of your data, ensuring that downstream calculations proceed without error and that your metrics reflect true mathematical values.