ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Parsing a string (https://www.excelbanter.com/excel-programming/363585-parsing-string.html)

neverends

Parsing a string
 

I'm trying to figure out a simple problem. I've looked around th
forum, but can't seem to find exactly what I'm looking for. I want t
take a hyperlink and cut off everything up until the last slash an
assign the remaining string to a variable.

I want to take this string:

Code
-------------------
http://www.something.com/xNet/MainSi...4&PgCxtDir=Dow
-------------------

...and end up with this string:

Code
-------------------
Profile.aspx?LID=12345678&RecentlyViewed=true&Item Index=14&PgCxtDir=Dow
-------------------


the closest I got was getting everything before the final slash to b
assigned to a variable. I know this is a simple problem, but
appreciate any help as I'm very new to VBA. Thanks in advance

--
neverend
-----------------------------------------------------------------------
neverends's Profile: http://www.excelforum.com/member.php...fo&userid=3504
View this thread: http://www.excelforum.com/showthread.php?threadid=54955


Tim Williams

Parsing a string
 
See help under

InStrRev - finds the last occurrence of a character in a string

--
Tim Williams
Palo Alto, CA


"neverends" wrote in message
...

I'm trying to figure out a simple problem. I've looked around the
forum, but can't seem to find exactly what I'm looking for. I want to
take a hyperlink and cut off everything up until the last slash and
assign the remaining string to a variable.

I want to take this string:

Code:
--------------------

http://www.something.com/xNet/MainSi...&PgCxtDir=Down
--------------------

..and end up with this string:

Code:
--------------------
Profile.aspx?LID=12345678&RecentlyViewed=true&Item Index=14&PgCxtDir=Down
--------------------


the closest I got was getting everything before the final slash to be
assigned to a variable. I know this is a simple problem, but I
appreciate any help as I'm very new to VBA. Thanks in advance.


--
neverends
------------------------------------------------------------------------
neverends's Profile: http://www.excelforum.com/member.php...o&userid=35045
View this thread: http://www.excelforum.com/showthread...hreadid=549550




Tom Ogilvy

Parsing a string
 
Dim s as String, v as Variant, s1 as String
s = "http://www.something.com/xNet/MainSite/Listing/Profile/Profile.aspx?
v = split(s,"/")
s1 = v(ubound(v))
msgbox s1

should work in xl2000 and later.

--
Regards,
Tom Ogilvy


"neverends" wrote:


I'm trying to figure out a simple problem. I've looked around the
forum, but can't seem to find exactly what I'm looking for. I want to
take a hyperlink and cut off everything up until the last slash and
assign the remaining string to a variable.

I want to take this string:

Code:
--------------------
http://www.something.com/xNet/MainSi...&PgCxtDir=Down
--------------------

...and end up with this string:

Code:
--------------------
Profile.aspx?LID=12345678&RecentlyViewed=true&Item Index=14&PgCxtDir=Down
--------------------


the closest I got was getting everything before the final slash to be
assigned to a variable. I know this is a simple problem, but I
appreciate any help as I'm very new to VBA. Thanks in advance.


--
neverends
------------------------------------------------------------------------
neverends's Profile: http://www.excelforum.com/member.php...o&userid=35045
View this thread: http://www.excelforum.com/showthread...hreadid=549550




All times are GMT +1. The time now is 01:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com