Phone number with area code mask number format.

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
704
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
I need to set a mask (cell number format) to do this:
Phone number can be with area code (lenght): 10 (2+8), 11 (2+9) or, without area code: 8 or 9. (non-us format)
Some aleatory (non real) numbers just for example:
12345678 result "1234-5678"
1212345678 result "(12) 1234-5678
123456789 result "12345-6789"
12123456789 result "(12) 12345-6789"
How can I do this?
Thanks
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You can set individual Custom formats but if you have a column of these different number formats I can't see that working.

You could format them into another column with CHOOSE

AB
1PhonePhone Formatted
2123456781234-5678
31212345678(12) 1234-5678
412345678912345-6789
512123456789(12) 12345-6789

<tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
B2=CHOOSE((LEN(A2)-7),TEXT(A2,"0000-0000"),TEXT(A2,"00000-0000"),TEXT(A2,"(00) 0000-0000"),TEXT(A2,"(00) 00000-0000"))

<tbody>
</tbody>

<tbody>
</tbody>

Otherwise I think you'll have to use VBA. I'm sure a VBA expert will be along shortly.
 
Upvote 0
I will save this solution by formula, but the initial idea is just a "numberformat" mask.
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top