Copy only the numbers from cells

  • Thread starter Thread starter Pandi
  • Start date Start date
P

Pandi

I have some table that in one column I have some strings (for example):
"Sum : 148,626.35 Better and different"
"Sum : 193,500.00 Osem"

I want only the number will be copy to another column.

How do I do that
 
Hi,

Write this code in a module you insert to your workbook
using VB Editor.

Public Function texttrim(a As String) As Double
Dim b As String
For i = 1 To Len(a)
If Asc(Mid(a, i, 1)) > 43 And Asc(Mid(a, i, 1)) < 58 Then
b = b + Mid(a, i, 1)
Next
texttrim = b
End Function

This will make a new worksheet function =texttrim()
available in your workbook which does exactly what you
need. For example if the text to be trimmed is in cell A1,
enter =texttrim(A1) to any other cell and you will get
just the number.

Regards,
 
Back
Top