# get only the numbers from a cell

#### outlawspeeder

##### Board Regular
Looking for code to pull numbers from a cell that has text with the number. I have some users that do not understand that excel cannot do math on cells with text and numbers.

Thank

Column A
abc 33
~rdt 45
& 344 fkfk
ddd 23 ss
44 dd 33

Result
33
45
344
23
4433

### Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

#### sandy666

##### Banned - Rules violations
use Power Query

 Column1 Number abc 33 33 ~rdt 45 45 & 344 fkfk 344 ddd 23 ss 23 44 dd 33 4433

Rich (BB code):
``````let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TS = Table.AddColumn(Source, "Number", each Text.Select([Column1], {"0".."9"})),
TypeNum = Table.TransformColumnTypes(TS,{{"Number", type number}}),
TSC = Table.SelectColumns(TypeNum,{"Number"})
in
TSC``````

#### Trevor G

##### Well-known Member
You could also try

VBA Code:
``````Sub DeleteText()
Dim cell As Range
Dim ran As Range
On Error Resume Next
Set ran = Range("a2:a500") 'Suggested range
For Each cell In ran
lOut = ""
For i = 1 To Len(cell.Value)
xTemp = Mid(cell.Value, i, 1)
If xTemp Like "[0-9]" Then
lStr = xTemp
Else
lStr = ""
End If
lOut = lOut & lStr
Next i
cell.Value = lOut
Next
End Sub``````

#### jmacleary

##### Well-known Member
Hello there. There are a number of sites that have this answer, I copied this function from one:
VBA Code:
``````Function GetNumeric(CellRef As String)
Dim StringLength As Integer
StringLength = Len(CellRef)
For i = 1 To StringLength
If IsNumeric(Mid(CellRef, i, 1)) Then Result = Result & Mid(CellRef, i, 1)
Next i
GetNumeric = Result
End Function``````

#### outlawspeeder

##### Board Regular
Trevor G

Thank you I can got where I need to be with what you provided

#### Trevor G

##### Well-known Member
Happy to help and thank you for letting us know you have a working solution.

Replies
7
Views
132
Replies
3
Views
46
Replies
12
Views
197
Replies
10
Views
168
Replies
0
Views
49

1,127,735
Messages
5,626,583
Members
416,192
Latest member
steinach

### 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.

### Which adblocker are you using?

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

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