Extract only numbers from a cell with text and numbers....

jamiguel77

Active Member
Joined
Feb 14, 2006
Messages
378
Office Version
  1. 2016
  2. 2010
  3. 2007
Platform
  1. Windows
  2. Web
hi all
i have in


A1 = 'LITROS DE LECHE 12,454.00 DE PROV1'
A2 = 'LITROS DE LECHE 274,354.20 DE PROV DE KANSAS'
A3 = 'KILOGRAMOS DE GRASA 1,612,564.00 DE PROVEEDOR DE JIMENEZ'
A4 = 'LITROS DE LECHE 429,573.00 DE TORREON'

with any formula i want extract only the numbers (isnt important if can get the ,)
B1 = 12,454.00
B2 = 274,354.20
B3 = 1,612,564.00
B4 = 429,573.00


any ideas? or only with VBA?

Thanks
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Can you use a VBA solution?
Ctrl + F11
paste this in blank space

Code:
Function removeAlpha(r As String) As String
With CreateObject("vbscript.regexp")
    .Pattern = "\D"
    .Global = True
    removeAlpha = .Replace(r, "")
End With
End Function

Then in B1 type =removealpha(A1) and drag down
 
Upvote 0
Hi,

If there's Always Only One number string within the data string, here's a formula you can use:


Book1
ABC
1LITROS DE LECHE 12,454.00 DE PROV112,454.0012454
2LITROS DE LECHE 274,354.20 DE PROV DE KANSAS274,354.20274354.2
3KILOGRAMOS DE GRASA 1,612,564.00 DE PROVEEDOR DE JIMENEZ1,612,564.001612564
4LITROS DE LECHE 429,573.00 DE TORREON429,573.00429573
Sheet59
Cell Formulas
RangeFormula
B1=TRIM(LEFT(SUBSTITUTE(MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),255)," ",REPT(" ",100)),100))
C1=LEFT(SUBSTITUTE(MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),255)," ",REPT(" ",100)),100)+0


Formulas copied down.

B1 formula results in TEXT, shows Exactly as within original string.
C1 formula converts results to Real NUMBERS, format cell to Number in format you want (i.e. with comma and/or 2 decimals)
 
Upvote 0
jtakw
Worked Fine! thanks


Roderick_E

the vba code return text cant format as a number.. how to fix

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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