By using t2do.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

 


Get the file name from the full path name

The following assumes a full path name is in cell A2 for example:

A2: C:\Laptop_backup\Flash Drive grey\Save\50 per day.xls

B2: =RIGHT(A2,LEN(A2)-FIND("@",SUBSTITUTE(A2,"\","@",LEN(A2)-LEN(SUBSTITUTE(A2,"\",""))),1))

The following VBA code will also get the file name


Function GetFileName(s)
for i = len(s) to 1 step -1
    if mid(s,i,1) = "/" then
       Getfilename = mid(s,i)
       exit for
    end if
next
end function