Extract Last Name After Mark "\" Without Extension in One Column

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..

i'm looking for a formula to figure out this problem. How to extract or get last name file without extension in single column, this just my sample
Book1
BC
2dataexpeted result
3D:\test\xxxxx\abc\a\1wbbm\ND 131.pdfND 131
4D:\test\zz\test\a\nd 346 himbauan.jpgnd 346 himbauan
5D:\test\Rekapitulasi.docxRekapitulasi
Sheet1


'i,m using Excel 2021 and please, don't use vba
anyone help, greatly appreciated..

susant
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
This is ms365 (as per your profile):

Book1
AB
1dataexpeted result
2D:\test\xxxxx\abc\a\1wbbm\ND 131.pdfND 131
3D:\test\zz\test\a\nd 346 himbauan.jpgnd 346 himbauan
4D:\test\Rekapitulasi.docxRekapitulasi
Sheet2
Cell Formulas
RangeFormula
B2:B4B2=TEXTBEFORE(TEXTAFTER(A2:A4,"\",-1),".")
Dynamic array formulas.


And this should work on Excel 2021:

Book1
AB
1dataexpected result
2D:\test\xxxxx\abc\a\1wbbm\ND 131.pdfND 131
3D:\test\zz\test\a\nd 346 himbauan.jpgnd 346 himbauan
4D:\test\Rekapitulasi.docxRekapitulasi
5D:\test\foo.tar.gzfoo
Sheet2
Cell Formulas
RangeFormula
B2:B5B2=FILTERXML("<t><s>"&SUBSTITUTE(FILTERXML("<t><s>"&SUBSTITUTE(A2,"\","</s><s>")&"</s></t>","//s[last()]"),".","</s><s>")&"</s></t>","//s[1]")
 
Last edited:
Upvote 1
Solution
And this should work on Excel 2021:
Up to the OP of course, but if such data is possible, row 5 does not look correct to me.
Given the comment in post #3 I am assuming that the file name itself does not contain a "." character apart from before the file name extension.
If that is the case then this simpler one should also work in 2021

23 02 24.xlsm
BC
2dataexpeted result
3D:\test\xxxxx\abc\a\1wbbm\ND 131.pdfND 131
4D:\test\zz\test\a\nd 346 himbauan.jpgnd 346 himbauan
5D:\test\Rekapitulasi.docxRekapitulasi
File Name
Cell Formulas
RangeFormula
C3:C5C3=LET(t,TRIM(RIGHT(SUBSTITUTE(B3,"\",REPT(" ",99)),99)),LEFT(t,FIND(".",t)-1))
 
Upvote 0
@Peter_SSs

Yeah, it is just an example of file-extensions having dots. In this case a tar.gz file. Probably irrelevant.
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,305
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top