Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This will work for you. Hope this helps! If so, let me know, click "YES"
below. Sub GetFileName() Dim myFullPath As String Dim myDirs As Variant Dim myFileName As String myFullPath = "C:\temp\temp1\temp2" myDirs = Split(myFullPath, "\") myFileName = myDirs(UBound(myDirs)) End Sub -- Cheers, Ryan "xhm" wrote: Hello: I am trying to locate the last subdirectory name from a full path. For example, I have a full path like: "c:\temp\temp1\temp2" I would like to find the temp2 which is the last subdirectory. I am thinking to use find() to find the last "\", and then use left(), right() or mid() to obtain it. The problem is, when I tried to use find() function, it only returns the first position of the "\" in the full path string. How can I get the last "\" position in the string? p.s., I had searched the Internet, but all the examples I found were just had one occurance of the char to be found, while in my case, I have multiple same chars ("\") in the string. Thanks for any help in advance. . |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I find a value from one cell in a char string in another? | Excel Worksheet Functions | |||
FIND 1 char in cell of any 3 char =True | Excel Discussion (Misc queries) | |||
Find char in string and mark | Excel Programming | |||
How to verify the first char of the string in excel? | Excel Discussion (Misc queries) | |||
How to verify the first char of the string in excel? | Excel Discussion (Misc queries) |