Introduction
The RIGHT function in Excel extracts a specified number of characters from the end of a text string. It is useful for extracting invoice numbers, product codes, employee ID suffixes, and other information from company data.
In this RIGHT Function in Excel tutorial, you will learn the RIGHT function through practical business examples, complete student tasks, and a final challenge.
RIGHT Function Syntax
=RIGHT(text, [num_chars])
- text: The text or cell containing the data.
- num_chars: The number of characters to extract from the right. This argument is optional.
Question 1: Extract the Last Four Digits of Invoice Numbers
Problem Statement
A company stores invoice numbers in Excel. The accounts department wants to extract the last four characters of each invoice number for quick identification.
| Invoice Number | Extracted Code |
|---|---|
| INV-2026-5817 | 5817 |
| INV-2026-7249 | 7249 |
| INV-2026-9035 | 9035 |
| INV-2026-4162 | 4162 |
Assume invoice numbers are stored in cells A2.
Excel Formula
=RIGHT(A2,4)
Expected Result: 5817 for the first invoice.
Student Task: Add a new invoice number INV-2026-8374 in cell A6. Use the formula to extract its last four characters.
New Expected Result: 8374
Question 2: Extract Product Category Codes
Problem Statement
A company uses product codes that end with a two-character category identifier. The inventory team wants to extract these identifiers.
| Product Code | Category Code |
|---|---|
| LAPTOP-IT | IT |
| CHAIR-OF | OF |
| PHONE-MB | MB |
| TABLE-FN | FN |
Assume product codes are stored in cells A2.
Excel Formula
=RIGHT(A2,2)
Expected Result: IT for the first product.
Student Task: Add a new product code MONITOR-EL in cell A6. Extract its final two characters.
New Expected Result: EL
Question 3: Extract the Last Three Characters of Order IDs
Problem Statement
The sales department wants to identify orders using the last three characters of each order ID.
| Order ID | Last Three Characters |
|---|---|
| ORD-45821 | 821 |
| ORD-73946 | 946 |
| ORD-61257 | 257 |
| ORD-89413 | 413 |
Assume order IDs are stored in cells A2.
Excel Formula
=RIGHT(A2,3)
Expected Result: 821 for the first order.
Student Task: Add the order ID ORD-62579 in cell A6. Extract its last three characters.
New Expected Result: 579
Question 4: Extract Employee Codes After Removing Extra Spaces
Problem Statement
An HR department receives employee codes with unwanted spaces at the beginning and end. Extract the last four characters after cleaning the text.
| Employee Code | Extracted Code |
|---|---|
EMP-5832 | 5832 |
EMP-7146 | 7146 |
EMP-9025 | 9025 |
EMP-6281 | 6281 |
Assume employee codes are stored in cells A2.
Excel Formula
=RIGHT(TRIM(A2),4)
Expected Result: 5832 for the first employee.
Student Task: Enter EMP-7459 in cell A6. Use the formula to remove the extra spaces and extract the last four characters.
New Expected Result: 7459
Question 5: Extract the Last Character from Employee Names
Problem Statement
A company wants to practise extracting the final character of each employee’s name.
| Employee Name | Last Character |
|---|---|
| Rahul | l |
| Priya | a |
| Aman | n |
| Simran | n |
Assume employee names are stored in cells A2.
Excel Formula
=RIGHT(A2)
Expected Result: l for Rahul.
Student Task: Add the name Karan in cell A6. Extract its last character.
New Expected Result: n
Student Tasks: RIGHT Function in Excel
Complete these exercises independently. Enter your formulas in the Expected Result column.
Task 1: Extract the Last Five Characters
| Product Reference | Expected Result |
|---|---|
| PROD-EXCEL58231 | 58231 |
| PROD-EXCEL71642 | 71642 |
| PROD-EXCEL90354 | 90354 |
Task: Extract the last five characters from each product reference.
Task 2: Extract Department Identifiers
| Department Code | Expected Result |
|---|---|
| COMPANY-HR | HR |
| COMPANY-IT | IT |
| COMPANY-FN | FN |
Task: Extract the last two characters from each department code.
Task 3: Extract the Last Four Characters
| Transaction ID | Expected Result |
|---|---|
| TXN-2026-4827 | 4827 |
| TXN-2026-6391 | 6391 |
| TXN-2026-7514 | 7514 |
Task: Write a formula to extract the last four characters of each transaction ID.
Final Student Challenge: Build an Inventory Code Summary
Problem Statement
You work as an inventory analyst for a company. The inventory manager stores product codes in Excel and wants you to extract useful information from the end of each code.
Use the following data:
| Product Name | Inventory Code | Required Output |
|---|---|---|
| Laptop | INV-2026-58321 | Last 5 characters |
| Mouse | STOCK-AB47 | Last 2 characters |
| Keyboard | ITEM-927 | Last 3 characters |
| Monitor | PROD-EXCEL125 | Last 3 characters |
| Printer | BATCH-7418 | Last 4 characters |
| Webcam | INV-2026-63924 | Last 5 characters |
Your Tasks
- Extract the required number of characters from each inventory code using the RIGHT function.
- Use cell references instead of typing codes directly into formulas.
- Apply the formulas to all rows using the fill handle.
- Add a new product named
Headphoneswith inventory codeINV-2026-74286and extract the last five characters. - Verify that all results contain the correct number of characters.
Expected Results
| Product Name | Expected Output |
|---|---|
| Laptop | 58321 |
| Mouse | 47 |
| Keyboard | 927 |
| Monitor | 125 |
| Printer | 7418 |
| Webcam | 63924 |
| Headphones | 74286 |
Bonus Challenge: If cell A2 contains PEN, what will =RIGHT(A2,10) return? Explain why Excel returns that result.
Final Goal: Build an inventory worksheet that extracts the required characters from product codes and updates automatically when new products are added.
Key Takeaways
- The RIGHT function in excel extracts characters from the end of text.
- The
num_charsargument specifies how many characters to return. - If
num_charsis omitted, Excel returns the last character. - If the text is shorter than the requested length, Excel returns the entire text.
- Combining RIGHT Function with TRIM helps remove unwanted leading and trailing spaces.
- RIGHT returns text, even when the extracted characters look like numbers.
Frequently Asked Questions (FAQs)
1. What is the RIGHT function in Excel?
The RIGHT function extracts a specified number of characters from the end of a text string.
2. What is the syntax of the RIGHT function?
The syntax is =RIGHT(text, [num_chars]).
3. What happens if I omit num_chars?
Excel returns only the last character of the text.
4. Can RIGHT extract numbers from an invoice ID?
Yes. For example, =RIGHT(A2,4) extracts the last four characters of an invoice ID. The result is text, even if it contains only digits.
5. What happens if I request more characters than the text contains?
Excel returns the entire text rather than producing an error.
6. Can I combine RIGHT with TRIM?
Yes. =RIGHT(TRIM(A2),4) removes leading and trailing spaces before extracting the last four characters.
7. What is the difference between LEFT and RIGHT?
LEFT extracts characters from the beginning of text, whereas RIGHT extracts characters from the end.
8. Can RIGHT extract text after a hyphen?
RIGHT extracts a fixed number of characters from the end. If you need to extract a variable-length section after a hyphen, TEXTAFTER may be more suitable in supported Excel versions.

