Spreadsheet formula to correctly format telephone numbers

When working in spreadsheet software such as Apple Numbers or OpenOffice.org Calc, you can easily remove formatting characters (brackets, dashes, spaces, etc.) from and add leading zeroes to multiple telephone numbers using a formula.

In this example, I’m assuming that your telephone numbers are all on the A Column. Starting with the cell in the B Column immediately adjacent to the first telephone number in the A Column, enter this formula (update the ‘A2‘ below as needed):

=substitute(substitute(substitute(substitute
  (substitute(substitute(substitute(substitute
  (A2, "/", ""), ".", ""), " ", ""), "(", ""), ")", ""),
  "-", ""), "+", ""), "&", "")

… then highlight the B Column cells downwards from this cell until you reach the row containing the last telephone number in the A Column. In Numbers, click the ‘Insert‘ option in the menubar and choose ‘Fill‘->’Fill Down‘. In OpenOffice.org, click the ‘Insert‘ option in the menubar and choose ‘Fill‘->’Down‘.

To automatically add leading zeroes to telephone numbers when they are formatted, follow the steps above but use the following formula instead (update the ‘A2‘ below as needed):

=if(mid(A2,1,1) = "0",substitute(substitute(substitute
  (substitute(substitute(substitute(substitute
  (substitute(A2, "/", ""), ".", ""), " ", ""), "(", ""),
  ")", ""), "-", ""), "+", ""), "&", ""),
  concatenate("0", substitute(substitute
  (substitute(substitute(substitute(substitute
  (substitute(substitute(A2, "/", ""), ".", ""), " ",
  ""), "(", ""), ")", ""), "-", ""), "+", ""), "&", "")))

Please note: If you are using OpenOffice.org, replace all commas (‘,’) with semicolons (‘;’) in the formulas above to make them work.

 

Related posts:

  1. Numbers ‘09 Quick Tip – Formula entry
  2. Disabling auto-formatting of telephone numbers by the Skype Browser Plugin
  3. Configure Gmail IMAP accounts properly in Apple Mail and on the iPhone
  4. How to get a free iTunes Store account anywhere in the world
  5. Creating a Recent Items Stack on the Dock in Mac OS X
Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!

Afrigator