Get Folder Name

djl0525

Well-known Member
Joined
Dec 11, 2004
Messages
1,240
I know how to get the file path...

=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1),1)-1)

But is there a way to get just the FOLDER name (not the entire path) of the current file?

DJ
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try this...

=TRIM(MID(SUBSTITUTE(CELL("filename",A1),"",REPT(" ", 100)),(LEN(CELL("filename",A1))-LEN(SUBSTITUTE(CELL("filename",A1),"",""))-1)*100,100))
 
Upvote 0
What exactly do you get as a result of this?


=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1),1)-1)
 
Upvote 0
I get the path to the file

C:\Users\...\...\...\folder name I want\

Is there a way to capture the characters between the last two backslashes?

DJ
 
Upvote 0
No, and it can change if/when the file is moved or copied to another computer.

Can we count the backslashes from the right?
 
Upvote 0
I was going to try and help, but I am getting the #VALUE! error with all of the formulae mentioned so far. Sorry!
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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