Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Wish to parse through a text string to find data

Hello:

I have string that looks like:

c:\temp\TstDir\Excel.xls

I wish to parse through & dif out the name of the file:
Excel.xls; Dir: TstDir

Is there an easy way to accomplish this?

Thanks,
-Neil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Wish to parse through a text string to find data

Hi Neil,

There are a few ways to do this:

Sub test()
Dim s As String
Dim nPos As Integer
Dim nPos2 As Integer

s = "c:\temp\TstDir\Excel.xls"

nPos = InStrRev(s, Application.PathSeparator)
nPos2 = InStrRev(s, Application.PathSeparator, nPos - 1)
Debug.Print "Filename: " & Mid$(s, nPos + 1)
Debug.Print "Folder: " & Mid$(s, nPos2 + 1, nPos - nPos2 - 1)
End Sub

Sub test2()
Dim s As String
Dim v As Variant
Dim n As Integer

s = "c:\temp\TstDir\Excel.xls"
v = Split(s, Application.PathSeparator)
n = UBound(v)

Debug.Print "Filename: " & v(n)
Debug.Print "Folder: " & v(n - 1)
End Sub


Both of these methods require Excel 2000 or later. If you are on 97 or
earlier, you'll have to parse through the string from beginning to end using
InStr() or Mid$().

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Neil Bhandar wrote:
Hello:

I have string that looks like:

c:\temp\TstDir\Excel.xls

I wish to parse through & dif out the name of the file:
Excel.xls; Dir: TstDir

Is there an easy way to accomplish this?

Thanks,
-Neil


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Wish to parse through a text string to find data

Or roll your own InStrRev UDF. Some non-optimized VBA5 equivalents
of VBA6 string functions are listed at

http://support.microsoft.com/default...b;en-us;188007


In article ,
"Jake Marx" wrote:

Both of these methods require Excel 2000 or later. If you are on 97 or
earlier, you'll have to parse through the string from beginning to end using
InStr() or Mid$().

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
Parse A String into Two xlmate Excel Worksheet Functions 11 February 21st 09 04:06 AM
parse text string Dave F[_2_] Excel Worksheet Functions 4 April 29th 07 07:48 AM
Parse this string David Excel Discussion (Misc queries) 2 February 20th 07 04:57 AM
Parse data where break is a first uppercase character in a string? Glen Excel Worksheet Functions 5 April 16th 06 07:28 PM
Macro to find text string in a column and paste data in another nicolascap Excel Discussion (Misc queries) 8 March 14th 06 03:13 PM


All times are GMT +1. The time now is 02:58 AM.

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

About Us

"It's about Microsoft Excel"