Hi There,
Try the following function
Function CleanedNumber(RawNumber) As String
CleanedNumber1 = ""
For i = 1 To Len(RawNumber)
If IsNumeric(Mid(RawNumber, i, 1)) = True Then
CleanedNumber = CleanedNumber & Mid(RawNumber, i, 1)
End If
Next i
End Function
Put this function in any Module and then in the worksheet use this as
a formula. Like EX. +CleanedNumber (A1)
Let me know if you can make it.
Regards
Richard / Ankur
www.xlmacros.com
On Feb 5, 9:24 am, guillermo.ht
wrote:
I have two columns (A:B) of data in my spreadsheet where people enter
telephone numbers. To enforce the integrity of the data in these columns, I
need a macro that will select columns A:B and remove all non-numerical
characters. 0-9 is all I want. I need to remove spaces and the a host of
other things such as dash, slash, dot, and parenthesis.
I have a macro that trims the leading spaces, and runs through a long
find/replace routine, but I wondered if there is a more graceful and better
way to remove everything that isn't a number 0-9 from these range of cells.
For example: 919-123-4567 or 919.123.4567 would become 9191234567
Any suggestions?