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

I have a string that looks like this:

15;18;22;25

or like this

2;89

How can I extract it so it returns only the numbers from the string.
So in the first case it would be 15 18 22 25 etc..

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default extract string

Hi Dreamer,

Sub Tester()

Dim sStr As String
Dim i As Long
Dim v As Variant

sStr = "15;18;22;25"

v = Split(sStr, ";")

For i = LBound(v) To UBound(v)
MsgBox v(i)
Next i

End Sub

I believe that the Split function was added in xl2. If you are using an
earlier version then you could use the following function supplied by Tom
Ogilvy:

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

---
Regards,
Norman


"dreamer " wrote in message
...
I have a string that looks like this:

15;18;22;25

or like this

2;89

How can I extract it so it returns only the numbers from the string.
So in the first case it would be 15 18 22 25 etc...


---
Message posted from http://www.ExcelForum.com/



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

Just use DataText to Columns with a delimiter of ;.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"dreamer " wrote in message
...
I have a string that looks like this:

15;18;22;25

or like this

2;89

How can I extract it so it returns only the numbers from the string.
So in the first case it would be 15 18 22 25 etc...


---
Message posted from http://www.ExcelForum.com/



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
extract numbers from a string Dave Excel Worksheet Functions 3 August 7th 08 09:43 PM
Extract given and surname a string Bob Maloney Excel Worksheet Functions 3 April 29th 07 03:27 AM
Extract from string mark Excel Discussion (Misc queries) 2 August 8th 06 12:38 PM
Extract sub string sixbeforedawn Excel Worksheet Functions 2 October 24th 05 09:50 AM
Extract Part of String [email protected] Excel Worksheet Functions 1 June 9th 05 08:33 AM


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