RIGHT Function in Excel: Complete Tutorial with Examples

RIGHT extracts characters from the end of text, gets file extensions and suffixes, splits last names, and parses endings efficiently.

Need to extract characters from the end of text? RIGHT returns a specified number of characters from the right side of a text string. It’s perfect for extracting file extensions, suffixes, or the last parts of codes.

What Makes RIGHT Useful

RIGHT extracts text from the end:

  • Extract suffixes – Get file extensions, domain endings, or last digits
  • Split data – Separate last names or trailing information
  • Data parsing – Pull account numbers, zip codes, or reference codes
  • Code extraction – Get IDs or identifiers from the end of strings
  • Format parsing – Extract last parts of dates, addresses, or filenames
The Syntax
=RIGHT(text, [num_chars])

Text is your source string. Num_chars is how many characters to extract from the right. If omitted, returns just the last character.


Example 1: Extract File Extension

Get file types from filenames:

Formula: =RIGHT(A2, 3)

Result in B2: pdf

Takes the last 3 characters from the right.


Example 2: Extract Last Name

Get last names from full names:

Formula: =RIGHT(A2, LEN(A2)-SEARCH(" ", A2))

Result in B2: Smith

Finds the space, calculates characters after it, extracts from the right.


Example 3: Extract Last 4 Digits

Get last 4 digits of account numbers:

Formula: =RIGHT(A2, 4)

Result in B2: 5678

Returns the last 4 characters.


Example 4: Extract Domain Extension

Get domain endings from URLs:

Formula: =RIGHT(A2, LEN(A2)-SEARCH(".", A2))

Result in B2: com

Finds the period, extracts everything after it.


Example 5: Get Last Character

Extract last letter or digit:

Formula: =RIGHT(A2, 1)

Result in B2: A

Returns just the last character.


Example 6: Extract Zip Code

Get zip codes from full addresses:

Formula: =RIGHT(A2, 5)

Result in B2: 12345

Assumes zip code is always last 5 characters.


RIGHT vs Similar Functions
Common Use Cases

File Extensions Extract .pdf, .xlsx, .jpg from filenames.

Last Name Extraction Separate surnames from combined name fields.

Account Identifiers Pull last digits for verification or display.

Domain Suffixes Get .com, .org, .co.uk from domains.

Practical Combinations

Extract after last delimiter:

=RIGHT(A2, LEN(A2)-SEARCH("~", SUBSTITUTE(A2, "-", "~", LEN(A2)-LEN(SUBSTITUTE(A2, "-", "")))))

Gets text after the last dash.

Last word only:

=RIGHT(A2, LEN(A2)-SEARCH("~", SUBSTITUTE(A2, " ", "~", LEN(A2)-LEN(SUBSTITUTE(A2, " ", "")))))

Remove first N characters:

=RIGHT(A2, LEN(A2)-3)

Removes 3 characters from the start.

Extract extension with period:

=RIGHT(A2, LEN(A2)-FIND(".", A2)+1)
Dynamic Extraction Length

Extract from last delimiter to end:

=RIGHT(A2, LEN(A2)-SEARCH("@", A2))

Extract based on cell value:

=RIGHT(A2, B2)

B2 contains the number of characters.

Extract last numeric characters:

=RIGHT(A2, LEN(A2)-MAX(IFERROR(FIND({0,1,2,3,4,5,6,7,8,9}, A2), 0))+1)
Common Mistakes to Avoid

Number of Characters Too Large

  • RIGHT doesn’t error if num_chars exceeds text length
  • Returns the entire text string
  • RIGHT("Hi", 10) = “Hi”

Counting from Wrong End

  • RIGHT counts from the end, not from a position
  • To get “last 5 after position 10”, use MID instead
  • RIGHT always starts from the very end

Text vs Numbers

  • RIGHT returns text, even if extracting numbers
  • “123” looks like 123 but is text
  • Use VALUE to convert: VALUE(RIGHT(A2, 4))
Error Handling

Check for delimiter existence:

=IF(ISNUMBER(SEARCH(".", A2)), RIGHT(A2, LEN(A2)-SEARCH(".", A2)), "")

Handle missing data:

=IFERROR(RIGHT(A2, LEN(A2)-SEARCH(" ", A2)), A2)

Ensure minimum length:

=IF(LEN(A2)>=4, RIGHT(A2, 4), A2)
Working with Numbers

Convert extracted text to number:

=VALUE(RIGHT(A2, 4))

Extract and calculate:

=VALUE(RIGHT(A2, 5)) + 1000

Preserve leading zeros:

=TEXT(VALUE(RIGHT(A2, 5)), "00000")
Advanced Patterns

Extract between last two delimiters:

=MID(A2, SEARCH("~", SUBSTITUTE(A2, "-", "~", LEN(A2)-LEN(SUBSTITUTE(A2, "-", ""))-1))+1, SEARCH("~", SUBSTITUTE(A2, "-", "~", LEN(A2)-LEN(SUBSTITUTE(A2, "-", ""))))-SEARCH("~", SUBSTITUTE(A2, "-", "~", LEN(A2)-LEN(SUBSTITUTE(A2, "-", ""))-1))-1)

Extract last occurrence:

Last Dash: =RIGHT(A2, LEN(A2)-FIND("~", SUBSTITUTE(A2, "-", "~", LEN(A2)-LEN(SUBSTITUTE(A2, "-", "")))))

Case conversion while extracting:

=UPPER(RIGHT(A2, 1))

Gets last character in uppercase.

Tips for Using RIGHT

Combine with TRIM Remove extra spaces before extracting:

=RIGHT(TRIM(A2), 4)

Use with SUBSTITUTE Replace characters before extracting:

=RIGHT(SUBSTITUTE(A2, "-", ""), 5)

Chain with other text functions LEFT + MID + RIGHT for complete text parsing.

File Path Parsing

Extract filename from path:

=RIGHT(A2, LEN(A2)-SEARCH("~", SUBSTITUTE(A2, "\", "~", LEN(A2)-LEN(SUBSTITUTE(A2, "\", "")))))

Get file extension:

=RIGHT(A2, LEN(A2)-SEARCH(".", A2))

Extract drive letter (use LEFT instead):

=LEFT(A2, 2)
Data Cleaning Examples

Remove trailing spaces:

=TRIM(A2)

Better than RIGHT for this purpose.

Remove last character:

=LEFT(A2, LEN(A2)-1)

Actually use LEFT, not RIGHT.

Extract numeric suffix:

=VALUE(RIGHT(A2, SUMPRODUCT(--ISNUMBER(--RIGHT(A2, ROW(INDIRECT("1:"&LEN(A2))))))))
When to Use RIGHT

Use RIGHT when:

  • Data ends with what you need
  • Extracting fixed-length suffixes
  • Getting file extensions or domain endings
  • Extracting last N characters

Don’t use RIGHT when:

  • You need the beginning of text (use LEFT)
  • You need middle characters (use MID)
  • Extracting based on start position (use MID)
Start Using It

Open a spreadsheet with text data. Pick a cell with text where you need the ending. Type =RIGHT, specify the cell and how many characters. See the extracted text instantly.

RIGHT becomes essential for extracting endings, extensions, and suffixes.


Questions about RIGHT? Want to explore MID for middle text extraction? Let’s connect.