+ Reply to Thread
Results 1 to 5 of 5

How to extract filename from path\filename

  1. #1
    Registered User
    Join Date
    05-25-2012
    Location
    california, usa
    MS-Off Ver
    excel 2010
    Posts
    2

    How to extract filename from path\filename

    I have several thousand path/filenames in a spreadsheet, one path\filename per cell in column A. I'm trying to figure out a formula that will extract the filename only. The problem is finding the last "\" and then extracting everything to the right. There could be zero or many "\" characters. Any help is appreciated. Sample data:

    c:\FileB.jpg
    controls.txt
    c:\documents and settings\UserA\FileA.txt
    c:\SOP\containers\dishrack\types\explanation.doc

    Thanks, Mark

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: How to extract filename from path\filename

    Assuming data starts in A1, try:

    =TRIM(RIGHT(SUBSTITUTE(A1,"\",REPT(" ",100)),100))

    copied down
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: How to extract filename from path\filename

    Ingenious, NBVC!
    Regards,
    Vandan

  4. #4
    Registered User
    Join Date
    05-25-2012
    Location
    california, usa
    MS-Off Ver
    excel 2010
    Posts
    2

    Re: How to extract filename from path\filename

    Wow, I am humbled, NVBC. This works perfectly. I spent many hours experimenting and searching the net before I posted here. I will study it, understand it, and add new tools to my Excel toolbox. Thank you very much!

    Mark

  5. #5
    Registered User
    Join Date
    08-04-2011
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: How to extract filename from path\filename

    Big thanks to NBVC! That is a brilliant formula. Saved me a lot of effort!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1