Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Dim strPN As String
strPN = "(617) 868-8332"
strPN = Replace(strPN, "(", "")
strPN = Replace(strPN, ")", "")
strPN = Replace(strPN, "/", " ") [green]'for 617/731-3413[/green]
MsgBox strPN
Public Function PhoneFormat(Phone As Variant) As Variant
Dim i As Integer
Dim char As String
Dim cleanFormat As String
If Not IsNull(Phone) Then
For i = 1 To Len(Phone)
char = Mid(Phone, i, 1)
'strip only the digits
If Asc(char) > 47 And Asc(char) < 58 Then
cleanFormat = cleanFormat & char
End If
Next i
Debug.Print cleanFormat & vbCrLf
If Len(cleanFormat) = 10 Then
For i = 1 To 10
char = Mid(cleanFormat, i, 1)
PhoneFormat = PhoneFormat & char
If i = 3 Or i = 6 Then PhoneFormat = PhoneFormat & "-"
Next i
Else
PhoneFormat = Phone
End If
End If
End Function