Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Retreiving only numeric values from a string

There are two parts I am trying to accomplish for a set of data I have in
column A.

What I have Results I would like
A1:kkdd55dd B1:55
A2:eaa5788ee B2:5788
A3:sfse B3:455
A4:
A5:
A6:455dae

If possible I wanted to have a function where it would Search at a range
from A1:A10 and place the first set of numbers it found (always be together)
in B1, the second set of numbers it finds placed in B2 and so on. As a
reminder I cannot download any type of files if that is to be suggested.

-thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Retreiving only numeric values from a string

Hi Alex,

Try posting the following user defined
function into a standard module:

'=============
Public Function NumberOnly( _
sStr As String) As Variant
Dim oRegExp As Object

Application.Volatile
Set oRegExp = CreateObject("VBScript.RegExp")

With oRegExp
.IgnoreCase = True
.Global = True
oRegExp.Pattern = "/d"
NumberOnly = .Replace(sStr, vbNullString)
If IsNumeric(NumberOnly) Then _
NumberOnly = CDbl(NumberOnly)
End With
End Function
'<<=============

With the data of interest in A1:A10.
enter:

=NumberOnly(A1)

in B1 and drag the formula down to B10.



---
Regards.
Norman


"Alex" wrote in message
...
There are two parts I am trying to accomplish for a set of data I have in
column A.

What I have Results I would like
A1:kkdd55dd B1:55
A2:eaa5788ee B2:5788
A3:sfse B3:455
A4:
A5:
A6:455dae

If possible I wanted to have a function where it would Search at a range
from A1:A10 and place the first set of numbers it found (always be
together)
in B1, the second set of numbers it finds placed in B2 and so on. As a
reminder I cannot download any type of files if that is to be suggested.

-thank you


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Retreiving only numeric values from a string

Try this non VBA attempt

=--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"01234567 89")),SUMPRODUCT(--ISNUMBER(--MID(A1,ROW($1:$1000),1))))

Mike

"Alex" wrote:

There are two parts I am trying to accomplish for a set of data I have in
column A.

What I have Results I would like
A1:kkdd55dd B1:55
A2:eaa5788ee B2:5788
A3:sfse B3:455
A4:
A5:
A6:455dae

If possible I wanted to have a function where it would Search at a range
from A1:A10 and place the first set of numbers it found (always be together)
in B1, the second set of numbers it finds placed in B2 and so on. As a
reminder I cannot download any type of files if that is to be suggested.

-thank you

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Retreiving only numeric values from a string

Hi Alex.

As Mike has introduced the possibility
of a non VBA approach, see:


Extracting numbers from alphanumeric strings
http://office.microsoft.com/en-us/ex...549011033.aspx


---
Regards.
Norman


"Alex" wrote in message
...
There are two parts I am trying to accomplish for a set of data I have in
column A.

What I have Results I would like
A1:kkdd55dd B1:55
A2:eaa5788ee B2:5788
A3:sfse B3:455
A4:
A5:
A6:455dae

If possible I wanted to have a function where it would Search at a range
from A1:A10 and place the first set of numbers it found (always be
together)
in B1, the second set of numbers it finds placed in B2 and so on. As a
reminder I cannot download any type of files if that is to be suggested.

-thank you


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Retreiving only numeric values from a string

Hi Alex,

oRegExp.Pattern = "/d"


Should read:

oRegExp.Pattern = "\D+"

and:

Application.Volatile


is unnecessary.

Therefore, replace the suggested function with:

'=============
Public Function NumberOnly( _
sStr As String) As Variant
Dim oRegExp As Object

Set oRegExp = CreateObject("VBScript.RegExp")

With oRegExp
.IgnoreCase = True
.Global = True
oRegExp.Pattern = "\D+"
NumberOnly = .Replace(sStr, vbNullString)
If IsNumeric(NumberOnly) Then _
NumberOnly = CDbl(NumberOnly)
End With
End Function
'<<=============



---
Regards.
Norman


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Retreiving only numeric values from a string

Thank you Norman and Mike, both methods worked great. I appreciate both
responses.

"Norman Jones" wrote:

Hi Alex.

As Mike has introduced the possibility
of a non VBA approach, see:


Extracting numbers from alphanumeric strings
http://office.microsoft.com/en-us/ex...549011033.aspx


---
Regards.
Norman


"Alex" wrote in message
...
There are two parts I am trying to accomplish for a set of data I have in
column A.

What I have Results I would like
A1:kkdd55dd B1:55
A2:eaa5788ee B2:5788
A3:sfse B3:455
A4:
A5:
A6:455dae

If possible I wanted to have a function where it would Search at a range
from A1:A10 and place the first set of numbers it found (always be
together)
in B1, the second set of numbers it finds placed in B2 and so on. As a
reminder I cannot download any type of files if that is to be suggested.

-thank you


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
TO DELETE ONLY NUMERIC VALUES IN A CHARACTER AND NUMERIC CELL IN ramesh k. goyal - abohar[_2_] Excel Discussion (Misc queries) 1 October 28th 09 06:50 AM
How do I replace last numeric string from a alphanumeric string? Christy Excel Discussion (Misc queries) 3 August 11th 06 12:17 AM
Extrapolate numeric values from text string Henrik Excel Worksheet Functions 4 November 3rd 05 06:25 PM
Extracting numeric values from string RJF Excel Worksheet Functions 3 January 5th 05 10:48 PM
Giving the String expression for Numeric Values.... Arijit Chatterjee Excel Programming 2 November 19th 03 10:57 AM


All times are GMT +1. The time now is 10:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"