Grabbing a file's extension means finding the text after the last dot — easy with TEXTAFTER, and still doable in older Excel with a SUBSTITUTE trick.
The -1 tells TEXTAFTER to count delimiters from the end, so multi-dot names work.
The example
Filenames with one or more dots; you want just the extension.
| A | B | |
|---|---|---|
| 1 | Filename | Extension |
| 2 | report.xlsx | xlsx |
| 3 | q3.final.docx | docx |
| 4 | photo.backup.jpg | jpg |
The formula
Modern Excel makes this one function:
How it works
Why the -1 matters:
- TEXTAFTER returns the text after a delimiter you choose — here a dot.
- A positive instance counts from the left; a negative instance counts from the right.
-1means 'the last dot', soq3.final.docxcorrectly returnsdocx.- In older Excel, the SUBSTITUTE/REPT trick below does the same job.
Add LOWER() around it if you want extensions normalised to lowercase.
Try it: interactive demo
Type a filename — the extension after the last dot appears live.
Variations
Works in older Excel
Push the last segment to the right with padded spaces, then trim.
Get the name without extension
TEXTBEFORE with -1 returns everything before the final dot.
Pitfalls & errors
A filename with no dot makes TEXTAFTER return #N/A. Wrap it in IFERROR to show a blank or the whole name.
Hidden double extensions (file.xlsx.txt) return the real last one (txt) — useful for spotting mislabelled files.
Practice workbook
Frequently asked questions
Why not just take the last three characters?
What if there's no extension?
Does this work with full file paths?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class