Help extracting only numbers from a string of text and numbers

LittleM

New Member
Joined
Jul 9, 2013
Messages
28
Hello,

I need help finding a way to extract only the numbers from a string of text and numbers. I have a ton of rows that look like (spaces included):
at point X=632517.4350 Y=2774893.1403 Z=1540.0075 starting width 0.4000 ending width 0.8000

<tbody>
</tbody>

And ideally I would like a result that looks like something along the lines of :

632517.4350, 2774893.1403, 1540.0075, 0.4000, 0.8000

as I need to upload the data into another program that will read comma delineated files.

Any help is much appreciated!

Thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi
Welcome to the board

Is your input always exactly like what you posted, meaning are the strings always "X=", "starting width", etc.?
 
Upvote 0
You can do FIND and REPLACE
  • FIND:at point X= REPLACE:Empty
  • FIND:Y= REPLACE:", " without quotes
  • FIND:Z= REPLACE:", " without quotes
  • FIND:starting width REPLACE:", " without quotes
  • FIND:ending width REPLACE:", " without quotes
 
Upvote 0
Another way is to replace the strings with commas using a formula.

Try:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"at point X=",""),"Y=",","),"Z=",","),"starting width ",","),"ending width ",",")
 
Upvote 0
Yet another way is through VBA. Assuming your data are in column A starting in A1:
Code:
Sub GetNumbersOnly()
Dim lR As Long, vA As Variant, R As Range, S As Variant, sO As String
lR = Range("A" & Rows.Count).End(xlUp).Row
Set R = Range("A1", "A" & lR)
R.Replace "?=", ""
vA = R.Value
For i = LBound(vA, 1) To UBound(vA, 1)
    S = Split(vA(i, 1), " ")
    For j = LBound(S) To UBound(S)
        If IsNumeric(S(j)) Then
            sO = sO & ", " & S(j)
        End If
    Next j
    R.Cells(i, 1).Value = Right(sO, Len(sO) - 2)
    sO = vbNullString
Next i
End Sub
 
Upvote 0
"=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"at point X=",""),"Y=",","),"Z=",","),"starting width ",","),"ending width ",",")"

This worked! Thank you so much, I appreciate it!
 
Upvote 0
Assuming decimal point will always be there:
Code:
Public Sub GetNumsOnly()
Dim r As Range
For Each r In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    r.Offset(0, 1).Value = Join(Filter(Split(Replace(r.Value, "=", " "), " "), ".", True), ",")
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,456
Messages
6,124,939
Members
449,197
Latest member
k_bs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top