Available in:All versions (Works in Excel 2007, every later version, Microsoft 365 and Excel for the web)Examples need Excel 2021 or laterCategory:Text

RIGHT

RECHTS in Dutch Excel

Returns a chosen number of characters from the end of a text, counting back from the last character.

Difficulty rating 1 of 5. It is LEFT counted from the other end; the only thinking happens when the length has to be calculated with LEN.

Last updated: 13 October 2026

See the worked examples

Sheet excerpt: C2 holds the formula
RowABC
1Entry no.JournalSequence
225-0412VRK0412=RIGHT(A2, 4)=RIGHT(A2; 4)
325-0413VRK
425-0415VRK
525-0416VRK
Formula cell (C2)Input

Result: 0412

=RIGHT(A2, 4)
=RIGHT(A2; 4)

What RIGHT does and when to use it

What it does: it returns the last characters of a text, for example the sequence number at the end of an entry number.

When to use it: when the part you need ends at the last character and has a known length, or one you can calculate as LEN minus something. After a delimiter, TEXTAFTER is clearer (Excel 2024 or Microsoft 365); for a part in the middle, use MID.

How Excel evaluates it

Excel reads text and converts a number to text if needed. It reads num_chars, or uses 1 when it is missing. It then counts that many characters back from the last one, including any spaces at the end, and returns them in their original order as a new text value.

The result is always text, so a suffix of digits such as 0147 keeps its leading zero and does not calculate until you convert it.

Watch out: RIGHT counts a trailing space as a character, so RIGHT(A2) can return what looks like an empty cell. Check the length with LEN, and wrap the text in TRIM: RIGHT(TRIM(A2)).

Mental model

Reading the last few letters of a word on a sign by starting at the right edge and moving left, then reading them back in normal order.

RIGHT(text, [num_chars])
RIGHT(text; [num_chars])
Arguments
ArgumentTypeMeaningDefault
textRequiredThe text to take characters from; usually a cell reference.
num_charsOptionalHow many characters to take from the right. Leave it out and you get 1.1

Return value:Text: num_chars characters from the end of text

Formulas use commas (,) between arguments, as in English Excel. Formulas use semicolons (;) between arguments, as in Dutch Excel. Formulas use commas (,) between arguments, as in English Excel; Dutch Excel uses semicolons (;).

Worked examples

Beginner

Take the sequence number from entry numbers

In the XAF auditfile of Veldhuis Installatie BV the sales journal VRK has entry numbers like 25-0412: the year and a four-digit sequence number. For the completeness test of the journal you want the sequence number in its own column, so that a missing number stands out.

Sheet excerpt: C2 holds the formula
RowABCD
1Entry no.JournalSequence
225-0412VRK0412=RIGHT(A2, 4)=RIGHT(A2; 4)
325-0413VRK
425-0415VRK
525-0416VRK
6
Formula cell (C2)Input

Formula in C2

=RIGHT(A2, 4)
=RIGHT(A2; 4)

Result: 0412

Step by step
  1. Excel reads text: A2 holds 25-0412, 7 characters. The year 25 is characters 1 and 2, the hyphen is 3, and 0412 is 4 to 7.
  2. It reads num_chars: 4. Counting back from the last character, position 7, the four characters are 7, 6, 5 and 4.
  3. It returns them in reading order: 0412. C2 shows 0412, with the leading zero, because the result is text.
  4. Copy C2 down to C5: 0413, 0415, 0416. Reading the column, the jump from 0413 to 0415 shows that entry 25-0414 is missing from the journal.
  5. Change the 4 to 2 and C2 shows 12, the last two characters. With 20, more than the 7 that exist, C2 shows the whole entry number without an error.

Watch out: To calculate the gap you need numbers: 0415 - 0413 works because Excel converts text in arithmetic, but MAX or SUM over the column returns 0, since they ignore text in a range. Wrap in VALUE when you want to aggregate.

More on this example: why it works, 1 variation

Why it works

The sequence number is the last part of the entry number and always four characters wide, so counting back 4 from the end lands on it in every row. Because RIGHT returns text, the zero padding survives, which is what you want when you read the numbers against each other.

Variations

=VALUE(RIGHT(A2, 4))
=VALUE(RIGHT(A2; 4))

Returns the number 412 instead of the text 0412, for sorting, MAX and gap calculations.

Intermediate

Read the VAT code from supplier invoice references

In the purchase journal INK the bookkeeper typed the VAT code as the last character of the invoice reference:

  • H for 21%
  • L for 9%
  • N for no VAT

To recalculate the VAT you want that code in its own column. The references were exported from the auditfile, and one of them has a space at the end.

Sheet excerpt: C3 holds the formula
RowABCD
1Invoice no.AmountVAT code
2INK-40817-H€1,250.00€ 1.250,00
3INK-40818-L€860.00€ 860,00L=RIGHT(TRIM(A3))=RIGHT(TRIM(A3))
4INK-40819-N€415.50€ 415,50
5INK-40820-H€3,200.00€ 3.200,00
6
Formula cell (C3)InputMarks: extra spaceNote: A3 is INK-40818-L followed by one space: 12 characters instead of 11.

Formula in C3

=RIGHT(TRIM(A3))
=RIGHT(TRIM(A3))

Result: L

Step by step
  1. Excel evaluates TRIM(A3) first. A3 is INK-40818-L plus a trailing space, 12 characters. TRIM drops the space and returns INK-40818-L, 11 characters.
  2. RIGHT has no num_chars, so it uses the default, 1. It takes the last character of the cleaned text, position 11, which is L.
  3. C3 shows L, so the 9% rate applies and the VAT on 860.00 should be 860 × 9% = 77.40.
  4. Without TRIM, RIGHT(A3) takes position 12 of the original, which is the space. C3 would look empty, and the VAT test would report a reference without a VAT code.
  5. Copy the formula to C2:C5. The clean references are unaffected by TRIM: C2 shows H, C4 shows N, C5 shows H.

Watch out: A non-breaking space at the end, common in text pasted from client e-mails and PDF extracts, survives TRIM and gives the same empty-looking result. If LEN(TRIM(A3)) is still 12, that is the cause.

More on this example: why it works, 1 more pitfall, 1 variation

Why it works

Leaving out num_chars is correct because the VAT code is exactly one character. RIGHT counts from whatever the last character is, visible or not, so the formula has to guarantee that the last character is a real one; TRIM does that before RIGHT counts.

More to watch out for

  • RIGHT keeps the case as typed, so a bookkeeper who typed a lowercase l gives l in C3. A normal = comparison ignores case, but EXACT does not, so use = when you test against the code table.

Variations

=RIGHT(TRIM(A3), 2)
=RIGHT(TRIM(A3); 2)

Returns -L, the hyphen and the VAT code, if you want to confirm the separator is where you expect it.

Advanced

Strip a journal prefix of varying length

In the journal entry test the full entry numbers start with the journal code, a hyphen, then year and sequence number: MEMO-25-0007, BNK1-25-0211. The journal codes differ in length. To match the entries against the client's list of manual entries you want the part after the first hyphen, without the journal.

Sheet excerpt: C3 holds the formula
RowABCD
1Entry no.DebitYear and sequence
2VRK-25-0412€12,450.00€ 12.450,00
3MEMO-25-0007€860.00€ 860,0025-0007=RIGHT(A3, LEN(A3) - FIND("-", A3))=RIGHT(A3; LEN(A3) - FIND("-"; A3))
4BNK1-25-0211€3,200.00€ 3.200,00
5BNK-ING-25-0102€1,475.50€ 1.475,50
6
Formula cell (C3)Input

Formula in C3

=RIGHT(A3, LEN(A3) - FIND("-", A3))
=RIGHT(A3; LEN(A3) - FIND("-"; A3))

Result: 25-0007

Step by step
  1. Excel evaluates the two inner functions first. LEN(A3) counts MEMO-25-0007: MEMO is 4, the hyphen 1, 25 is 2, the hyphen 1, 0007 is 4. 4 + 1 + 2 + 1 + 4 = 12.
  2. FIND("-", A3) scans from the left: M, E, M, O, then the hyphen at position 5. It stops at the first hyphen and returns 5.
  3. The subtraction gives the number of characters after that hyphen: 12 - 5 = 7.
  4. RIGHT(A3, 7) counts back 7 characters from the end and returns 25-0007. C3 shows 25-0007.
  5. Copied to C2, VRK-25-0412 gives 11 - 4 = 7 and 25-0412. In C4, BNK1-25-0211 gives 12 - 5 = 7 and 25-0211. The prefix length differs every time, and the formula measures it every time.
  6. In C5 it goes wrong without a warning: BNK-ING-25-0102 has 15 characters and its first hyphen at 4, so RIGHT returns 11 characters, ING-25-0102. The journal code itself contains a hyphen.

Watch out: As row 5 shows, a hyphen inside the journal code gives a wrong result with no error, and the entry will then not match the client's list. Here year and sequence are always the last 7 characters, so RIGHT(A5, 7) is safer than counting from the front.

More on this example: why it works, 1 more pitfall, 2 variations

Why it works

RIGHT wants the number of characters to keep, and LEN minus the position of the delimiter is exactly that number. Instead of describing the prefix, you describe where it ends, which works for any prefix length. The result depends on the first hyphen being the end of the prefix; when that assumption breaks, the formula still returns something plausible.

More to watch out for

  • An entry number without any hyphen makes FIND return #VALUE!, and the whole formula with it. That error is useful: it marks an entry that does not follow the numbering pattern.

Variations

=RIGHT(A3, 7)
=RIGHT(A3; 7)

When the part you keep has a fixed width, count from the end and ignore the prefix entirely; this also handles BNK-ING.

=MID(A3, FIND("-", A3) + 1, LEN(A3))
=MID(A3; FIND("-"; A3) + 1; LEN(A3))

MID from the character after the hyphen gives the same result; some people find start-and-length simpler to read than keep-the-last-n.

MasterExcel 2021 or later (This example needs Excel 2021 or later)

Get the file name from the end of a path

To follow up the debtor and creditor confirmations you have a list of the files in the audit folder, each with its storage path. The paths have different depths, from none to four folders. You need the file name alone, everything after the last slash, to match against the confirmation list, and the formula has to work in any Excel version your colleagues use.

Sheet excerpt: C2 holds the formula
RowABCD
1PathSize (KB)File name
2Audit/2025/D/conf_D1001.pdf212212conf_D1001.pdf=LET( path, A2, width, LEN(path), wide, SUBSTITUTE(path, "/", REPT(" ", width)), TRIM(RIGHT(wide, width)) )=LET( path; A2; width; LEN(path); wide; SUBSTITUTE(path; "/"; REPT(" "; width)); TRIM(RIGHT(wide; width)) )
3Audit/2025/D/NL/conf_D1002.pdf187187
4Audit/2025/C/conf_C2001.pdf305305
5conf_D1003.pdf9696
6
Formula cell (C2)Input

Formula in C2

=LET(
  path, A2,
  width, LEN(path),
  wide, SUBSTITUTE(path, "/", REPT(" ", width)),
  TRIM(RIGHT(wide, width))
)
=LET(
  path; A2;
  width; LEN(path);
  wide; SUBSTITUTE(path; "/"; REPT(" "; width));
  TRIM(RIGHT(wide; width))
)

Result: conf_D1001.pdf

Step by step
  1. path is A2, Audit/2025/D/conf_D1001.pdf. width is LEN(path): Audit 5, slash 1, 2025 4, slash 1, D 1, slash 1, conf_D1001.pdf 14. 5 + 1 + 4 + 1 + 1 + 1 + 14 = 27.
  2. REPT(" ", width) makes a run of 27 spaces. SUBSTITUTE replaces each of the 3 slashes with that run. wide is now 27 - 3 + 3 × 27 = 105 characters: the folder names pushed far apart by wide gaps.
  3. RIGHT(wide, 27) takes the last 27 characters. The file name is 14 of them; the other 27 - 14 = 13 must come from the gap in front of it, because that gap is 27 spaces wide and cannot be crossed. No character of the folder D gets in.
  4. TRIM removes the 13 leading spaces. C2 shows conf_D1001.pdf.
  5. Copied to C3, the path is 30 characters with 4 slashes; the last gap is 30 spaces, RIGHT takes 30, and TRIM leaves conf_D1002.pdf. The number of folders does not matter, only the last gap does.
  6. In C5, conf_D1003.pdf has no slash. SUBSTITUTE changes nothing, RIGHT(wide, 14) returns all 14 characters, and TRIM leaves conf_D1003.pdf. The edge case needs no extra test.

Watch out: The mirror-image mistake is RIGHT(A2, LEN(A2) - FIND("/", A2)), which cuts at the first slash instead of the last. It returns 2025/D/conf_D1001.pdf, which looks like a path fragment and passes a quick glance.

More on this example: why it works, 2 more pitfalls, 1 variation

Why it works

RIGHT can only count from the end; it cannot search backwards for the last slash. The trick turns every slash into a gap at least as wide as the whole path, so a count of LEN characters from the end is guaranteed to hold the complete last segment and nothing but spaces before it. TRIM then removes those spaces.

Most versions of this trick online use a fixed 100 or 255; using LEN makes the width always sufficient.

Do not use this in Excel 2024 or Microsoft 365, where TEXTAFTER with instance_num -1 returns the last segment directly and says what it does. The trade-off: TEXTAFTER does not exist in Excel 2021 and older; the variation below drops LET as well, so it runs there.

More to watch out for

  • TRIM also collapses double spaces inside the file name and removes spaces at its edges. A file called conf D1001 signed.pdf comes back as conf D1001 signed.pdf, which no longer matches the real file.
  • Windows paths use a backslash. SUBSTITUTE looks only for the character you give it, so a path with backslashes passes through unchanged and TRIM returns the whole path. Replace "/" with "\" for those.

Variations

=TRIM(RIGHT(SUBSTITUTE(A2, "/", REPT(" ", LEN(A2))), LEN(A2)))
=TRIM(RIGHT(SUBSTITUTE(A2; "/"; REPT(" "; LEN(A2))); LEN(A2)))

The same without LET, for Excel 2019 and older: A2 appears three times, which is what LET avoids.

Common mistakes

Common mistakes
SymptomCauseFix
The last 4 characters, not the restTo remove a 4-character prefix you wrote RIGHT(A2, 4) and got the last 4 characters instead.num_chars is how many to keep, not how many to drop. Keep LEN(A2) - 4 characters: RIGHT(A2, LEN(A2) - 4).
Returns .5 instead of 50RIGHT(A2, 2) on an amount shown as 1,250.50 returns .5, not 50.RIGHT reads the stored value 1250.5, not the display. For text that matches the display, use TEXT with a format code first; for arithmetic, use MOD or ROUND instead.

Used in combinations

  • Find the customer with a regex lookupPull the invoice number out of a bank description with REGEXEXTRACT, turn it into a pattern, and let XLOOKUP match that pattern against an invoice list that is typed in different ways.Excel for Microsoft 365 (This combination needs Excel for Microsoft 365)