RIGHT
RECHTS in Dutch Excel
Returns a chosen number of characters from the end of a text, counting back from the last character.
Last updated: 13 October 2026
| Row | A | B | C |
|---|---|---|---|
| 1 | Entry no. | Journal | Sequence |
| 2 | 25-0412 | VRK | 0412=RIGHT(A2, 4)=RIGHT(A2; 4) |
| 3 | 25-0413 | VRK | |
| 4 | 25-0415 | VRK | |
| 5 | 25-0416 | VRK |
Swipe sideways to see all columns
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])
| Argument | Type | Meaning | Default |
|---|---|---|---|
text | Required | The text to take characters from; usually a cell reference. | |
num_chars | Optional | How 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.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Entry no. | Journal | Sequence | |
| 2 | 25-0412 | VRK | 0412=RIGHT(A2, 4)=RIGHT(A2; 4) | |
| 3 | 25-0413 | VRK | ||
| 4 | 25-0415 | VRK | ||
| 5 | 25-0416 | VRK | ||
| 6 |
Swipe sideways to see all columns
Formula in C2
=RIGHT(A2,4)
=RIGHT(A2;4)
Result: 0412
Step by step
- Excel reads text:
A2holds25-0412, 7 characters. The year 25 is characters 1 and 2, the hyphen is 3, and 0412 is 4 to 7. - It reads num_chars: 4. Counting back from the last character, position 7, the four characters are 7, 6, 5 and 4.
- It returns them in reading order: 0412.
C2shows 0412, with the leading zero, because the result is text. - Copy
C2down toC5: 0413, 0415, 0416. Reading the column, the jump from 0413 to 0415 shows that entry 25-0414 is missing from the journal. - Change the 4 to 2 and
C2shows 12, the last two characters. With 20, more than the 7 that exist,C2shows 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:
Hfor 21%Lfor 9%Nfor 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.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Invoice no. | Amount | VAT code | |
| 2 | INK-40817-H | €1,250.00€ 1.250,00 | ||
| 3 | INK-40818-L | €860.00€ 860,00 | L=RIGHT(TRIM(A3))=RIGHT(TRIM(A3)) | |
| 4 | INK-40819-N | €415.50€ 415,50 | ||
| 5 | INK-40820-H | €3,200.00€ 3.200,00 | ||
| 6 |
Swipe sideways to see all columns
Formula in C3
=RIGHT(TRIM(A3))
=RIGHT(TRIM(A3))
Result: L
Step by step
- Excel evaluates TRIM(A3) first.
A3isINK-40818-Lplus a trailing space, 12 characters. TRIM drops the space and returns INK-40818-L, 11 characters. - 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.
C3shows L, so the 9% rate applies and the VAT on 860.00 should be 860 × 9% = 77.40.- Without TRIM, RIGHT(A3) takes position 12 of the original, which is the space.
C3would look empty, and the VAT test would report a reference without a VAT code. - Copy the formula to
C2:C5. The clean references are unaffected by TRIM:C2shows H,C4shows N,C5shows 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.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Entry no. | Debit | Year and sequence | |
| 2 | VRK-25-0412 | €12,450.00€ 12.450,00 | ||
| 3 | MEMO-25-0007 | €860.00€ 860,00 | 25-0007=RIGHT(A3, LEN(A3) - FIND("-", A3))=RIGHT(A3; LEN(A3) - FIND("-"; A3)) | |
| 4 | BNK1-25-0211 | €3,200.00€ 3.200,00 | ||
| 5 | BNK-ING-25-0102 | €1,475.50€ 1.475,50 | ||
| 6 |
Swipe sideways to see all columns
Formula in C3
=RIGHT(A3,LEN(A3) - FIND("-", A3))
=RIGHT(A3;LEN(A3) - FIND("-"; A3))
Result: 25-0007
Step by step
- 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.
- 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.
- The subtraction gives the number of characters after that hyphen: 12 - 5 = 7.
- RIGHT(A3, 7) counts back 7 characters from the end and returns 25-0007.
C3shows 25-0007. - Copied to
C2, VRK-25-0412 gives 11 - 4 = 7 and 25-0412. InC4, BNK1-25-0211 gives 12 - 5 = 7 and 25-0211. The prefix length differs every time, and the formula measures it every time. - In
C5it 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.
| Row | A | B | C | D |
|---|---|---|---|---|
| 1 | Path | Size (KB) | File name | |
| 2 | Audit/2025/D/conf_D1001.pdf | 212212 | conf_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)) ) | |
| 3 | Audit/2025/D/NL/conf_D1002.pdf | 187187 | ||
| 4 | Audit/2025/C/conf_C2001.pdf | 305305 | ||
| 5 | conf_D1003.pdf | 9696 | ||
| 6 |
Swipe sideways to see all columns
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
- 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. - 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.
- 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.
- TRIM removes the 13 leading spaces.
C2shows conf_D1001.pdf. - 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. - 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
| Symptom | Cause | Fix |
|---|---|---|
| The last 4 characters, not the rest | To 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 50 | RIGHT(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)