SteveB Posted December 24, 2005 Posted December 24, 2005 Here's a Custom Function that formats phone numbers. It removes a leading '1' and handles 10 and 7 digits. If the format is incorrect (not 7 or 10), it changes the text color to red as an indicator for the user. It requires 1 function parameter called 'Phone': Let ( [ num = Filter ( Phone ;"0123456789" ); num = Case(Left(num;1)= "1"; Middle(num;2;20); num); len = Length(num) ]; Case( len = 10; TextColor(Left( num; 3) & " " & Middle( num; 4; 3) & "-" & Middle( num ;7;4); RGB(0;0;0)); // with area code len = 7; TextColor( Left( num; 3) & "-" & Middle( num;4;4); RGB(0;0;0)); // without area code TextColor(num; RGB(255;0;0) ) ) // wrong length so make text red ) See my other posting in this forum 'This is for Comment' for more flexible methods. Steve
Steverino Posted January 13, 2006 Posted January 13, 2006 What do you do about international numbers mixed with (mostly) domestic phone numbers?
SteveB Posted January 13, 2006 Author Posted January 13, 2006 My customers don't record international phone numbers, so I never put in the capability. Do all international phone numbers follow one standard format? Does it vary by country? Steve
Steverino Posted January 13, 2006 Posted January 13, 2006 Usually they start with the foreign-country code (011), but they might have any number of digits after that.
SteveB Posted January 13, 2006 Author Posted January 13, 2006 Then how can it be formatted? Does it always start with a '0'? Steve
Kent Searight Posted January 31, 2006 Posted January 31, 2006 Calling a foreign country from within the USA will always start with "011" (except country codes 808 and 809, Dominican Republic and Midway, respectively) but the country's code, which follows 011, can be from 1 to 5 digits long. I believe you'd need a database of all country codes to reference in your calc to make it work internationally. Hope this helps!
Recommended Posts
This topic is 6869 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now