Guys, I wonder if you can help?
I using a VBA Funtion to clean up UK phone numbers to the required '01234 567890' format.
I'm currently using three different steps to get the result - I'm looking for all three steps to be combined into one VBA function script - ideally added to the existing function below.
The current VBA function and first step is;
============================
Function CleanUpNumber(StrNumber)
Dim StrNoSpaces, StrNoPluses, StrNoBracketsA, StrNoBracketsB, StrFinalNumber
StrNoSpaces = Replace(StrNumber, " ", "")
StrNoPluses = Replace(StrNoSpaces, "+", "0")
StrNoBracketsA = Replace(StrNoPluses, "(", "")
StrNoBracketsB = Replace(StrNoBracketsA, ")", "")
If Left(StrNoBracketsB, 3) = "044" Then
StrFinalNumber = "0" & Right(StrNoBracketsB, Len(StrNoBracketsB) - 3)
Else
StrFinalNumber = StrNoBracketsB
End If
CleanUpNumber = StrFinalNumber
End Function
============================
I then use;
=REPT(0,11-LEN(A1))&A1
as a second step to get a leading zero [if required], and then;
=REPLACE(A1,6,0," ")
as a third step to add a space character for the correct '01234 567890' format
[ the raw number above being in Cell A1 ]
Below is a sample of the raw data.
+44 8802192025
08802 798559
08802798559
8815698257
Any help/pointer would be appreciated.
I using a VBA Funtion to clean up UK phone numbers to the required '01234 567890' format.
I'm currently using three different steps to get the result - I'm looking for all three steps to be combined into one VBA function script - ideally added to the existing function below.
The current VBA function and first step is;
============================
Function CleanUpNumber(StrNumber)
Dim StrNoSpaces, StrNoPluses, StrNoBracketsA, StrNoBracketsB, StrFinalNumber
StrNoSpaces = Replace(StrNumber, " ", "")
StrNoPluses = Replace(StrNoSpaces, "+", "0")
StrNoBracketsA = Replace(StrNoPluses, "(", "")
StrNoBracketsB = Replace(StrNoBracketsA, ")", "")
If Left(StrNoBracketsB, 3) = "044" Then
StrFinalNumber = "0" & Right(StrNoBracketsB, Len(StrNoBracketsB) - 3)
Else
StrFinalNumber = StrNoBracketsB
End If
CleanUpNumber = StrFinalNumber
End Function
============================
I then use;
=REPT(0,11-LEN(A1))&A1
as a second step to get a leading zero [if required], and then;
=REPLACE(A1,6,0," ")
as a third step to add a space character for the correct '01234 567890' format
[ the raw number above being in Cell A1 ]
Below is a sample of the raw data.
+44 8802192025
08802 798559
08802798559
8815698257
Any help/pointer would be appreciated.
Last edited: