I have a table exported from Access database via SQL query. In excel, there are 3 columns: ID, name and a phone number… The problematic is a phone number column. Users have put in numbers in all kinds of ways so it looks very untidy and i cant use that field for other purposes.
Lets say that the default way that i want to see the numbers is: 385991234567. So it has the country code, than the area code, then the number… but all together combined.
In the database i have inputs like:
0991234567 – so without the country code
991234567 – without the country code and the leading zero of the area code
+385991234567 – with + in front of the country code
99/1234-567 – with various character separating the groups of numbers (i’ve managed to clean that up through the replace in the sql query).
The thing i want is to achieve the format i mentioned in the beginning. so add the country code, if needed remove the leading zero. The additional problem is that some of the numbers are 7 digits, others are 6 digits (without the country or area codes). Ive tried to do the replace by searching the 099 for instance, but if it occurs in the middle of the number, it gets changed too.
I dont know what to do. Or even is this the right section for this question (because i dont know if it is easier to do it in excel, via VBA macro, via sql query or something else). I cant do it by hand because its a field of approx. 100.000 phone numbers.
OK, so here it is… for starters, i used some SQL Queries to select the specific phone numbers and clean up the junk characters from phone numbers…
and this one…
After that, i exported the data to excel and applied the next macro…
And thats about it… worked like a charm. The code may be messy or could be written better, but i am a novice, so i guess its ok 😀