Excel Formula: excel extract file extension from filename

In some cases, you may want to extract the file extensions form a list of filenames in Excel worksheet. Here in this tutorial, introduces two different formulas to quickly handle this job, also you can realize how the formulas work in Excel.
doc extract extension from file name 5

Formula 1 Using SEARCH, RIGHT and REPLACE functions

Generic formula:

REPLACE(RIGHT(filename,5),1,SEARCH(".",RIGHT(filename,5)),"")

Arguments

Filename: the filename you want to extract the extension.

How this formula work

To extract the extension of filename in cell B3, please use the formula:

=REPLACE(RIGHT(B3,5),1,SEARCH(".",RIGHT(B3,5)),"")

Press Enter key to the cell B8.to extract the extension.
doc abbreviate words 1

Explanation

RIGHT function is used to extract text from right side of a given text. Here RIGHT(B3,5) extracts 5 characters from right side of text in cell B3 since the longest length of extension is not longer than 5-digit. It returns “.xlsx”.

SEARCH function returns the location of the specific character or text from the given text string. Here SEARCH(".",RIGHT(B3,5)) finds the location of “.” in the text string “.xlsx” and returns 1.

REPLACE function finds and replaces characters based on given location from text string with a new text. REPLACE(RIGHT(B3,5),1,SEARCH(".",RIGHT(B3,5)),"") can be seen as REPLACE(".xlsx",1,1,""), it finds first character of the text string “.xlsx”, and replaces it with nothing.
doc extract extension from file name 2

Formula 2 Using LEN, RIGHT and FIND functions

Generic formula:

RIGHT(filename,LEN(filename)-FIND(".",filename))

Arguments

Filename: the filename you want to extract the extension.

How this formula work

To extract the extension of filename in cell B3, please use the formula:

=RIGHT(B3,LEN(B3)-FIND(".",B3))

Press Enter key to the cell B8.to extract the extension.
doc extract extension from file name 3

Explanation

FIND function returns the starting position of a string inside another one. FIND(".",B3) find the starting position of “.” in cell B3, it returns 15.

LEN function used to count the number of characters.

RIGHT function is used to extract text from right side of a given text. Here =RIGHT(B3,LEN(B3)-FIND(".",B3)) can be seen as RIGHT(B3,18-15), it extracts 3 characters from right side of the text in cell B3.
doc extract extension from file name 4

Sample File

doc sampleClick to download sample file


Relative Formulas


Relative Functions


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.