Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Trim string vII

Ok, next question, how would you keep all the text starting from the right
up until you encounter a "\"?

Jesse


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Trim string vII

One way:


Sub getName()
Dim str As String
str = "C:\MyWebServer\MyFolder\MyPage.htm"

str = Left(str, Len(str) - 4)

Dim x As Integer
Dim lenStr As Long
Dim newString As String
lenStr = Len(str)

For x = lenStr To 0 Step -1
If Mid(str, x, 1) = "\" Then
x = 0
Else
newString = Mid(str, x, 1) & newString
End If
Next
Debug.Print newString


End Sub

--
Michael Hopwood (Phobos)


"Jesse Hamilton" wrote in message
news:BxSrb.16169$jy.13609@clgrps13...
Ok, next question, how would you keep all the text starting from the right
up until you encounter a "\"?

Jesse




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Trim string vII

If you use a function from Tom Ogilvy (working in 97-2003)

Function Split97(sStr As Variant, sdelim As String) As Variant
Split97 = Evaluate("{""" & _
Application.Substitute(sStr, sdelim, """,""") & """}")
End Function


Sub test2()
Dim fname As String
Dim sfname As String
Dim varr As Variant
fname = "C:\testfile.htm"
varr = Split97(fname, "\")
sfname = varr(UBound(varr))

MsgBox sfname

End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Jesse Hamilton" wrote in message news:BxSrb.16169$jy.13609@clgrps13...
Ok, next question, how would you keep all the text starting from the right
up until you encounter a "\"?

Jesse




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
Trim out last seven characters from a string... DubboPete Excel Discussion (Misc queries) 3 February 2nd 10 05:16 AM
How to trim a string to the last "." VCKW Excel Discussion (Misc queries) 23 November 28th 07 08:36 PM
trim a string by specific number of characters windyoldman Excel Discussion (Misc queries) 2 July 13th 05 01:53 PM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM
Trim like worksheet Trim Bob Phillips[_5_] Excel Programming 0 August 20th 03 07:10 PM


All times are GMT +1. The time now is 07:24 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"