Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Return part of string AFTER LAST ":"

Hi there,

Following problem on which I could not find a solution ...


In cell A2 there could be a string as follows:

abcd:lalala:dedsfs:Sige

or it could be:

dsfsfs:hrthr:TomOgilvy

What I would like to return is the part of the string AFTER the last ":"
In my first example there are 3 ":" in muy second it are 2 of them.

But it could be any number... (at least1!)

Someone who can sort me this out?

Sigeeeeee
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Return part of string AFTER LAST ":"

newText holds the resultant string you require

Dim myText, newText As String
Dim char As String
Dim i, counter, textLen As Integer

myText = ActiveCell.Value
textLen = Len(myText)

counter = textLen
Do Until char = ":"
char = Mid(myText, counter, 1)
counter = counter - 1
Loop

newText = Mid(myText, counter + 2, textLen - counter + 2)

Regards
Rowan

"SIGE" wrote:

Hi there,

Following problem on which I could not find a solution ...


In cell A2 there could be a string as follows:

abcd:lalala:dedsfs:Sige

or it could be:

dsfsfs:hrthr:TomOgilvy

What I would like to return is the part of the string AFTER the last ":"
In my first example there are 3 ":" in muy second it are 2 of them.

But it could be any number... (at least1!)

Someone who can sort me this out?

Sigeeeeee

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Return part of string AFTER LAST ":"

Assuming that there is at least one : in the string, you can use:

a="dsfsfs:hrthr:TomOgilvy"
debug.print mid(a,1+instrrev(a,":"))


"SIGE" wrote:

Hi there,

Following problem on which I could not find a solution ...


In cell A2 there could be a string as follows:

abcd:lalala:dedsfs:Sige

or it could be:

dsfsfs:hrthr:TomOgilvy

What I would like to return is the part of the string AFTER the last ":"
In my first example there are 3 ":" in muy second it are 2 of them.

But it could be any number... (at least1!)

Someone who can sort me this out?

Sigeeeeee

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Return part of string AFTER LAST ":"

Here is a way with just worksheet functions

=MID(A2,FIND("~",SUBSTITUTE(A2,":","~",LEN(A2)-LEN(SUBSTITUTE(A2,":",""))))+
1,255)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"SIGE" wrote in message
om...
Hi there,

Following problem on which I could not find a solution ...


In cell A2 there could be a string as follows:

abcd:lalala:dedsfs:Sige

or it could be:

dsfsfs:hrthr:TomOgilvy

What I would like to return is the part of the string AFTER the last ":"
In my first example there are 3 ":" in muy second it are 2 of them.

But it could be any number... (at least1!)

Someone who can sort me this out?

Sigeeeeee



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
=SUBSTITUTE(C4,"~?#","") will this work to remove multiple string Raja Mahendiran S Excel Worksheet Functions 6 May 12th 10 09:10 PM
If part of a cell = "NVA" then insert "Norfolk" in return cell RNCKWMN Excel Worksheet Functions 4 June 13th 09 08:53 PM
Converting "uppercase" string data to "lower case" in CSV file [email protected] Excel Discussion (Misc queries) 2 August 12th 08 08:36 PM
text string: "91E10" in csv file auto converts to: "9.10E+11" [email protected] Excel Discussion (Misc queries) 2 August 12th 08 03:13 PM
conditional formatting "if part of cell contents contains string" tom ossieur Excel Worksheet Functions 1 March 13th 07 11:11 AM


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