PC Review


Reply
Thread Tools Rate Thread

change text in string

 
 
CG Rosen
Guest
Posts: n/a
 
      5th Oct 2009
Hi Group,

Need some hints how to approach this problem;

In a cell I have a text string like "10-1,10-2,10-3,10-4" or the string
could be as
"1-1,1-2,1-3" or even "100-1,101-2"

I want the string to be converted to look like "1,2,3,4....etc

Grateful for some help.

Brgds

CG Rosen

 
Reply With Quote
 
 
 
 
SMS
Guest
Posts: n/a
 
      5th Oct 2009
I would look at the string to find the hyphen, then take all
characters after it.

MyPos = Instr(1, searchstring, "-", 1)
MyString = Mid(searchstring, MyPos+1)



On Oct 5, 1:02*pm, "CG Rosen" <carlgran.ro...@telia.com> wrote:
> Hi Group,
>
> Need some hints how to approach this problem;
>
> In a cell I have a text string like "10-1,10-2,10-3,10-4" or the string
> could be as
> "1-1,1-2,1-3" or even "100-1,101-2"
>
> I want the string to be converted to look like "1,2,3,4....etc
>
> Grateful for some help.
>
> Brgds
>
> CG Rosen


 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      5th Oct 2009
On Mon, 5 Oct 2009 22:02:51 +0200, "CG Rosen" <(E-Mail Removed)> wrote:

>Hi Group,
>
>Need some hints how to approach this problem;
>
>In a cell I have a text string like "10-1,10-2,10-3,10-4" or the string
>could be as
>"1-1,1-2,1-3" or even "100-1,101-2"
>
>I want the string to be converted to look like "1,2,3,4....etc
>
>Grateful for some help.
>
>Brgds
>
>CG Rosen


Assuming what you want is the number following a hyphen, and terminated by a
comma or the end of the line, then:

===================
Const s1 As String = "1-1,1-2,1-3"
Dim a() As String
Dim s As String
Dim i As Long

a = Split(s1, ",")
For i = 0 To UBound(a)
a(i) = Split(a(i), "-")(1)
Next i

s = Join(a, ",")
Debug.Print s
=================
--ron
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: change text in string SMS Microsoft Excel Programming 2 7th Oct 2009 04:59 AM
Change 3 letter text string to a number string Pete Microsoft Excel Misc 3 31st Dec 2007 07:47 PM
How to change text string? =?Utf-8?B?RGFqYW5h?= Microsoft Excel Misc 2 24th Aug 2005 02:29 AM
How to change text string to asterisk in text box Huayang Microsoft Access Security 2 7th Aug 2005 11:16 AM
change String text to be Form Object dom Microsoft Access Form Coding 4 22nd Jan 2005 02:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:09 AM.