Formula to get path from full file name...

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I need formula to get path from full file name...

Fullpath= C:\Docs\mybook.xls
Expected= C:\Docs

Thanks
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi Pedie :)

Code:
Sub pedie()
Dim s As String
With ActiveWorkbook
    s = Left(.FullName, InStrRev(.FullName, "\") - 1)
    MsgBox s
End With
End Sub

This should give the same result

Code:
s = ActiveWorkbook.Path
 
Upvote 0
Peter, thanks that works perfect...

Do we have it in excel formula too to get the path only from full file name?
Text ahead of "\"

Thanks again...
 
Upvote 0
Anyone?:)
I need a formula to give me the left part of text croping from last "\" in text...
 
Upvote 0
Try formula below

=LEFT(CELL("Filename",A1),FIND("[",CELL("Filename",A1))-2)

Biz
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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