View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Helmut Weber[_2_] Helmut Weber[_2_] is offline
external usenet poster
 
Posts: 163
Default Removing parentheses in a phone number

Hi,

I have no idea about the structure of supposedly american
phone numbers, but if all your phone numbers follow
this rule: 3 digits dash 3 digits dash 4 digits,
then it's easy. Too easy.

E.g.

Public Function Phone(s As String) As String
Dim t As String
Dim l As Long
For l = 1 To Len(s)
If IsNumeric(Mid(s, l, 1)) Then
t = t & (Mid(s, l, 1))
End If
Next
Phone = Format(t, "###-###-####")
End Function


However, as IMHO this will hardly be the case,
we, if I may say so, need a bit more of information.
If the rule above does not apply,
and there is no set of rules which covers all
possible variations, then for
e.g. 5555555555 there is no solution.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"