Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 389
Default Extract file name

What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Extract file name

On Fri, 8 Aug 2008 16:23:00 -0700, Steven
wrote:

What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven


It appears that the name will occur after the last "\".

So:

=MID(A1,1+FIND(CHAR(1),SUBSTITUTE(A1,"\",CHAR(1),
LEN(A1)-LEN(SUBSTITUTE(A1,"\","")))),255)

--ron
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Extract file name

You can use this array-entered** formula to do that...

=MID(A1,MAX((MID(A1,ROW(1:260),1)="\")*ROW(1:260)) +1,260)

** Commit this formula with Ctrl+Shift+Enter, not just Enter by itself

Rick


"Steven" wrote in message
...
What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Extract file name

On Fri, 8 Aug 2008 20:30:13 -0400, "Rick Rothstein \(MVP - VB\)"
wrote:

You can use this array-entered** formula to do that...

=MID(A1,MAX((MID(A1,ROW(1:260),1)="\")*ROW(1:260) )+1,260)

** Commit this formula with Ctrl+Shift+Enter, not just Enter by itself

Rick


Wouldn't it be better to use ROW($1:$260), so you can fill down without
changing the reference?
--ron
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 389
Default Extract file name

Thank you to you both.

"Rick Rothstein (MVP - VB)" wrote:

You can use this array-entered** formula to do that...

=MID(A1,MAX((MID(A1,ROW(1:260),1)="\")*ROW(1:260)) +1,260)

** Commit this formula with Ctrl+Shift+Enter, not just Enter by itself

Rick


"Steven" wrote in message
...
What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 947
Default Extract file name

What function would extract the name: 84DTCC 2008_05

If you would like a UDF...

Function GetFileName(strFilePath)
GetFileName = CreateObject("Scripting.FileSystemObject").GetFile Name(strFilePath)
End Function

Sub TestIt()
Dim s As String
s = "G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf"
Debug.Print GetFileName(s)
End Sub

Returns:
84DTCC 2008_05.pdf

--
HTH :)
Dana DeLouis


"Steven" wrote in message ...

What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Extract file name

Here is a UDF which does not rely on a scripting object (meaning it should
be a little bit faster)...

Function GetFileName(strFilePath)
GetFileName = Split(strFilePath, "\")(UBound(Split(strFilePath, "\")))
End Function

Rick


"Dana DeLouis" wrote in message
...
What function would extract the name: 84DTCC 2008_05


If you would like a UDF...

Function GetFileName(strFilePath)
GetFileName =
CreateObject("Scripting.FileSystemObject").GetFile Name(strFilePath)
End Function

Sub TestIt()
Dim s As String
s = "G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf"
Debug.Print GetFileName(s)
End Sub

Returns:
84DTCC 2008_05.pdf

--
HTH :)
Dana DeLouis


"Steven" wrote in message
...
What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven


  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Extract file name

You can use this array-entered** formula to do that...

=MID(A1,MAX((MID(A1,ROW(1:260),1)="\")*ROW(1:260 ))+1,260)

** Commit this formula with Ctrl+Shift+Enter, not just Enter by itself

Rick


Wouldn't it be better to use ROW($1:$260), so you can fill down without
changing the reference?


Yes, of course. I actually had that in my original test formulas, but some
error happened in it and, after I corrected it, I didn't notice that Excel
had removed the $ signs from the equation.

Rick

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Extract file name

Here is different version which also does not rely on a scripting object...

Function GetFileName(strFilePath)
GetFileName = Mid(strFilePath, InStrRev("\" & strFilePath, "\"))
End Function

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Here is a UDF which does not rely on a scripting object (meaning it should
be a little bit faster)...

Function GetFileName(strFilePath)
GetFileName = Split(strFilePath, "\")(UBound(Split(strFilePath, "\")))
End Function

Rick


"Dana DeLouis" wrote in message
...
What function would extract the name: 84DTCC 2008_05


If you would like a UDF...

Function GetFileName(strFilePath)
GetFileName =
CreateObject("Scripting.FileSystemObject").GetFile Name(strFilePath)
End Function

Sub TestIt()
Dim s As String
s = "G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf"
Debug.Print GetFileName(s)
End Sub

Returns:
84DTCC 2008_05.pdf

--
HTH :)
Dana DeLouis


"Steven" wrote in message
...
What function would extact the name: 84DTCC 2008_05
out of this.
G:\CorporateAcct\SMR\Special\Support\84DTCC 2008_05.pdf

Note that the directory and subdirectory(ies) will not be constant (ie.
some may have more or less "\" )

Thank you,

Steven



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba code for excel to extract data from txt file JE New Users to Excel 3 June 11th 07 09:19 PM
Can I extract a picture from an excel file and save it elsewhere? TiinaN Excel Discussion (Misc queries) 2 March 30th 07 02:41 PM
Extract from a file kkjensen Excel Discussion (Misc queries) 1 June 29th 06 08:55 PM
How to extract value from a different file? Firenzeitl Excel Worksheet Functions 1 April 22nd 06 07:16 AM
Macro to extract clip-art file? Terry Pinnell Excel Discussion (Misc queries) 0 February 11th 05 08:56 AM


All times are GMT +1. The time now is 07:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"