Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default change text in string

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
SMS SMS is offline
external usenet poster
 
Posts: 15
Default change text in string

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" 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default change text in string

On Mon, 5 Oct 2009 22:02:51 +0200, "CG Rosen" 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
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
change text in string SMS Excel Programming 0 October 5th 09 09:33 PM
How to change font color on string/text values [email protected] Excel Programming 2 March 31st 08 12:28 PM
Change a 1,2,3 or 4 digit number to a 6 character text string Steve D Excel Worksheet Functions 3 March 28th 08 08:14 PM
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
How to change text string? Dajana Excel Discussion (Misc queries) 2 August 24th 05 02:29 AM


All times are GMT +1. The time now is 10:43 PM.

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"