Function guides · Text

RIGHT function

Returns a number of characters from the end of text.

Syntax

=RIGHT(text, [num_chars])
ArgumentWhat it is
textThe text or cell to take characters from.
num_charsOptional. How many characters from the end. Defaults to 1.

What RIGHT does

RIGHT returns characters from the end of a piece of text. Ask for 4 and you get the last four.

It handles the end of codes, numbers and file names. Pair it with LEN and FIND when the part you want begins after a separator and its length is not fixed.

Like all text functions, it returns text. A string of digits from RIGHT looks like a number but behaves like a word until it is converted. LEFT does the same from the start, and MID from any point inside.

For the last word in a cell, a longer formula works: =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)). It pads every space to 100 characters, takes the last 100, and trims. The idea is clever but hard to read, so use it when the number of words varies and a simple FIND would not work.

For a fixed trailing pattern, such as a three-letter country code or a four-digit year at the end of a string, plain RIGHT is clearer and quicker to check.

Combine RIGHT with a text-to-number conversion when the end of a code is a quantity or a year. RIGHT(A2,2)*1 turns the last two characters of “BOX-24” into the number 24 in one step, because multiplying text that looks like a number makes Excel convert it. VALUE does the same job more explicitly.

RIGHT examples

1. Last four digits

Last four digits. The formula =RIGHT(A2,4) in cell B2 returns 8831.
AB
1AccountLast 4
24417-2290-88318831

RIGHT counts from the end. The last four characters of an account number are often the only part a report may show.

2. Last name from a full name

Last name from a full name. The formula =RIGHT(A2,LEN(A2)-FIND(" ",A2)) in cell B2 returns Tanaka.
AB
1Full nameLast name
2Mei TanakaTanaka

The last name has no fixed length. LEN gives the total length, FIND gives the position of the space, and the difference is how many characters follow it.

3. File extension

File extension. The formula =RIGHT(A2,3) in cell B2 returns pdf.
AB
1File
2report-2026.pdfpdf

Counting back from the end is how you get a file type. This takes the three characters after the final dot. It works only when every extension has three letters.

Common RIGHT mistakes

  • Assuming a fixed length. Extensions such as .xlsx or .jpeg have four characters. If lengths vary, find the dot with FIND and take LEN minus its position.
  • Trailing spaces. A cell ending in a space returns the space as one of the characters. Clean with TRIM first.
  • Result is text. RIGHT returns text, even for digits. Use VALUE to turn it into a number.
  • Names with more than one space. A full name such as Mary Ann Lee has two spaces, and the formula above returns "Ann Lee". Decide the rule first.

RIGHT on Excel job tests

Prompts like "take the last four digits of the phone number", "get the file extension" or "pull the last name" point to RIGHT. The variable-length ones need LEN and FIND together: RIGHT(A2, LEN(A2) - FIND(" ", A2)) gives the text after the first space.

Check names with more than one space before trusting that. Mary Ann Lee would come back as "Ann Lee".

RIGHT returns text. If the next step compares against numbers, convert with VALUE.

RIGHT questions

What does RIGHT do in Excel?
It returns the last characters of a text value, counting from the right.
How do I get everything after a character?
=RIGHT(A2,LEN(A2)-FIND("-",A2)) returns everything after the first dash.
Does RIGHT work on numbers?
Yes, treating them as text, and the result is text.
What if num_chars is larger than the text?
RIGHT returns the whole text.

Practice RIGHT

Try it in a working grid: the free lesson LEFT, RIGHT and MID: pull out part of a cell (module 9 of Everyday Excel) has checked RIGHT exercises.

Practice this function