Use Excel’s RIGHT function to return characters from the end of a text value. For example, if A2 contains the text INV-2026-0478, =RIGHT(A2,4) returns 0478. The function is useful for pulling out IDs, postal-code segments, file extensions, and other values whose position is counted from the right.
What the RIGHT function does
RIGHT takes text and returns a chosen number of characters starting at the end. It does not search for a particular word or symbol: it counts backward from the last character. That makes it especially handy when a code has a fixed-length suffix, such as the final four digits of an order number.
The returned result is text, even when the extracted characters look like a number. For example, keeping a code such as 0042 as text preserves its leading zeros. That can be important when the digits are an identifier rather than a quantity to calculate.
RIGHT works in Excel for Microsoft 365 on Windows, and its basic behavior is the same in Excel for Mac and Excel for the web. A formula can be entered in a cell or in the formula bar, then copied to other rows.
RIGHT syntax and character counts
The function has a required text argument and an optional number-of-characters argument. If you leave out the second argument, Excel returns just the final character. A count of zero returns an empty string; a count larger than the text length returns the entire text. A negative count produces a #VALUE! error.
- Text: the cell or text value to read from the right.
- Number of characters: how many characters to return. This can be a fixed number or a calculation.
For example, with A2 containing NORTH, the formula =RIGHT(A2) returns H. With A2 still containing NORTH, =RIGHT(A2,2) returns TH. The count includes spaces and punctuation as well as letters and digits.
Practical RIGHT formula examples
These examples use cell references so you can adapt them to a worksheet. Put the formula in a result column, such as B2, and replace the example cell or count with the values in your own data.
- Get the last four characters: with an order code in A2, where A2 contains INV-2026-0478, enter
=RIGHT(A2,4). The result is 0478. - Return a surname-like final word of a known length: with Maya Chen in A2, enter
=RIGHT(A2,4). The result is Chen. This works for this example because the desired ending has exactly four characters; it is not a general way to identify the final word in names of varying lengths. - Get the final four digits of a phone number: with 555-019-2846 stored in A2, enter
=RIGHT(A2,4). The result is 2846. If phone numbers may include extensions or varying punctuation, clean or standardize the source first so the last four characters really are the digits you need. - Return the final character: with a product code in A2, enter
=RIGHT(A2). Excel returns the final character without needing a count.
In the surname example, the four-character count is intentionally specific. RIGHT counts characters, not words, so it will not reliably extract a last name if the names have different lengths. For word-based extraction, use a delimiter-aware method instead.
Extract text after a separator
A common task is returning everything after a hyphen, underscore, or other separator. If the separator is always in the same position, a fixed RIGHT count may be enough. If the part before it varies in length, calculate the number of characters after the separator.
With North-4821 in A2, enter =RIGHT(A2,LEN(A2)-FIND("-",A2)). The result is 4821: LEN counts the full text, FIND locates the hyphen, and the subtraction gives the count of characters after it. This approach assumes that the separator appears in the cell. If it does not, FIND returns an error, so check that the source data follows the expected pattern.
When every value follows the same separator pattern, this formula can be filled down a column. If the data may contain several hyphens and you want everything after the last one, this particular formula is not enough: FIND locates the first matching hyphen. Consider cleaning the data or using a more suitable delimiter-based formula for the exact pattern.
Numbers, dates, and displayed formatting
Excel can use RIGHT with a number, but it treats the number as text for the extraction and returns text. The displayed cell format is a separate matter. A number formatted to show leading zeros or a currency symbol may not contain those displayed characters in its underlying value, so RIGHT may not return what you see on screen.
For example, suppose A2 contains the numeric value 1234 but is formatted to display as 001234. With A2 containing that number, =RIGHT(A2,2) returns 34. It does not extract the final two characters of the displayed format as a general rule. If leading zeros are part of a code, store the code as text or create the desired text representation before extracting characters.
Dates are also stored as numbers in Excel. Applying RIGHT directly to a date can therefore return characters from its serial-number value rather than from the date as displayed. If you need the end of a formatted date string, first convert the date to the intended text representation with an appropriate text-formatting approach, then extract from that result. Be clear about the desired date format, since day and month order can vary by locale.
If an extracted digit string must be used in arithmetic, convert it deliberately. With the text SKU-07 in A2, =VALUE(RIGHT(A2,2)) returns the number 7. This conversion removes the leading zero. Keep the result as text if 07 is an identifier that must retain its formatting.
Common problems and ways to fix them
Unexpected results often come from the source data rather than from the function. Before changing the formula, inspect the exact contents of the cell, including spaces, punctuation, and whether a value is stored as text or as a number.
- Extra spaces at the end: trailing spaces count as characters, so RIGHT may return spaces instead of the visible characters you expect. With a value such as ABCD followed by extra spaces in A2,
=RIGHT(TRIM(A2),4)returns ABCD. TRIM also reduces repeated internal spaces to single spaces, so use it only if that change is appropriate for the data. - #VALUE! error: check for a negative character count or an invalid count value. A calculation used as the second argument must produce zero or a positive number.
- Too many characters returned: if the requested count is longer than the source text, Excel returns the whole text. Check the count and the cell’s actual contents.
- Missing leading zeros: the extracted result may be text, but a later conversion to a number can remove zeros. Keep identifiers as text when their formatting matters.
- Wrong characters from a number or date: check whether Excel is reading the underlying value rather than the visible formatting. Convert or prepare the value as text when you need to work with a specific displayed representation.
Fill RIGHT formulas down a column
For a list of codes, enter the formula beside the first data row, then copy it down. If codes are in A2:A20, put the formula in B2 and use the fill handle—the small square at the lower-right corner of the selected cell—to copy it through B20. Excel adjusts the relative reference from A2 to A3, A4, and so on.
You can also select the formula cell and the blank cells below it, then use the Fill command on the Home tab. On Windows, Ctrl+D fills the selected range downward. On Mac, the equivalent is Control+D. Check a few results, especially the first and last rows, to ensure that the data has consistent lengths and separators.
If the source range is formatted as an Excel table, entering a formula in a table column commonly fills the formula down that calculated column automatically. This can make a list easier to maintain as rows are added. Excel for Mac and the web also support RIGHT and the fill handle, though ribbon layout and some keyboard behavior can differ by platform.
RIGHT compared with other text functions
RIGHT is the best fit when you need a fixed number of characters from the end. Use LEFT when you need characters from the beginning, or MID when you need characters from a specified position within the text. These functions count positions; they do not identify a word or category by meaning.
For more flexible delimiter-based extraction, TEXTAFTER can return text after a specified separator in Microsoft 365 or Excel 2024. For instance, it can be more direct than calculating a character count when the portion before a separator varies. RIGHT remains useful for fixed-width codes and older workbooks, while a delimiter-based function is often clearer when the separator defines the boundary.
Before choosing a method, ask whether the text has a stable length, whether the separator is guaranteed to exist, and whether the result should remain text. Those details determine whether a short RIGHT formula is reliable or whether the data needs a more flexible approach.
Frequently Asked Questions
How do I use RIGHT in Excel?
Enter a cell reference and the number of characters to return, such as =RIGHT(A2,4). Excel returns the final four characters from the value in A2.
What does RIGHT return if I leave out the number?
It returns one character: the last character in the text value. Include a count when you need more than one character or use zero for an empty result.
Can RIGHT extract the last word in a cell?
Not reliably by itself when words have different lengths. RIGHT counts characters, not words. Use a method based on the space or another separator when you need the final word from variable-length text.
Why does RIGHT return the wrong part of a number?
Excel may be extracting from the underlying numeric value, not the way that value is displayed with a custom format. If the number is an identifier, store or convert it to text in the format you need before extracting.
Does RIGHT work in Excel for Mac and Excel for the web?
Yes. The function and its basic syntax work in those versions as well as Excel for Microsoft 365 on Windows. The interface and some shortcuts may differ, but the same RIGHT formulas can be used.
Related
- How to Make a Number Superscript in Excel
- How to Make a Number Negative in Excel: Three Methods
- How to Make a Color Key in Excel for Clearer Sheets
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel Formula for Random Selection From a List: GuideTo return one random item from a contiguous list in Excel, use =INDEX(A2:A20,RANDBETWEEN(1,ROWS(A2:A20))). If your items are in…
- How to Find Variance in Excel: Formulas and ExamplesTo find variance in Excel, enter =VAR.S(B2:B6) for a sample or =VAR.P(B2:B6) for an entire population, replacing the…
- How to Remove Spaces in Excel With TRIM and SUBSTITUTETo clean extra spaces in Excel, use TRIM; to delete every ordinary space, use SUBSTITUTE. With the original…
- Excel Data Table Setup: What-If Analysis and TablesTo set up an Excel what-if data table, create a formula that refers to your model, arrange possible…
- Excel A to Z Formula: How to Sort DataWith the values to sort in A2:A20 and an empty output area beginning at C2, enter =SORT(A2:A20) in…
- How to Get Out of Filter Mode in Excel and Show All RowsTo get out of filter mode in Excel and show every row, select a cell in the filtered…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.