Extract folder from path - Excel Formula

Hi,

Pretty simple one I think...If I have say:

C:/folder1/folder2/folder3/folder4/folder5/file.xls....
..in a cell could I write a formula in the cell next to it that would extract the folder that the file is in, so for the above example the formula would return *folder5* as the file.xls is in folde5.

So basically the formula would be returing what is in the inbetween the last forward slashes /***/, 'folder5'..

Thanks
jasocke2Asked:
Who is Participating?
 
RichardSchollarConnect With a Mentor Commented:
Assuming that value is in A1 then perhaps:

=TRIM(LEFT(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",250)),500),250))

Note that I saw you had a forward slash as the folder delimiter - did you mean a backslash instead?  If so then:

=TRIM(LEFT(RIGHT(SUBSTITUTE(A1,"\",REPT(" ",250)),500),250))

Richard
0
 
jasocke2Author Commented:
Hi,

I did mean backslash!!

Works a treat, many thanks.

James
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.