View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Harlan Grove Harlan Grove is offline
external usenet poster
 
Posts: 733
Default Function to return filepath given full filename

"Tom Ogilvy" wrote...
....
If you have excel 2000 or later, you can use split to get the filename
sStr = "C:\Myfolder1\myfolder2\myfile.xls"
v = (sStr,"\")
sPath = Left(sStr,len(sStr)-v(ubound(v)))

....

If OP has XL2K or later, OP could use InStrRev.

p = InStrRev(sStr, "\")
sPath = IIf(p 0, Mid(sStr, p + 1), "")