Weird Phone number format question

AwfulSpider

New Member
Joined
Sep 25, 2020
Messages
15
Office Version
  1. 365
Platform
  1. Windows
So I get lists of phone numbers that I need to format in a weird way for batch uploads to our system, like this: +15555555555.

I get the numbers in a column in excel all kinds of ways, (555)5555555, 555-555-5555, 5555555555, you get the idea.
So what I’ve been doing is copy pasting ‘+1 (to keep the + sign) and deleting any extra bits. But these lists are hundreds of numbers long, so any formatting tricks would help greatly.
Thanks in advance!
 
Thank you for all your help, I have a code that's working now.
Well, you have a non-VBA and a VBA solution now.

The advantage to non-VBA is that it is not VBA (so you don't need to enable VBA/Macros, or anything like that).

The advantage to VBA is that you can do it without extra columns, and you can run it with a single click of a button.
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Give this formula a try...it will strip non-numeric characters and add a +1 to the front.
="+1"&TEXTJOIN("",TRUE,IFERROR(MID(C27,ROW(INDIRECT("1:15")),1)+0,""))

NOTE: This is an array formula so use CTRL+SHIFT+ENTER rather than just enter.

Just curious how is the above formula any different than a simple concatenation
"+1"&C27
Where Cell C27 has the original 10 digit phone number
 
Upvote 0
Just curious how is the above formula any different than a simple concatenation
"+1"&C27
Where Cell C27 has the original 10 digit phone number
Go back and read post #1. The entries aren't always exactly 10 numbers. There may be other characters as well.

I just discovered something else. The formula version does not handle blank or text entries well. It returns "+1" in those cells.
The VBA solution I provided handles that. It will only change it if it finds exactly 10 numbers in the cell. Otherwise, it will leave the cell "as-is".
Just something else to keep in mind.
 
Upvote 0
Go back and read post #1. The entries aren't always exactly 10 numbers. There may be other characters as well.

I just discovered something else. The formula version does not handle blank or text entries well. It returns "+1" in those cells.
The VBA solution I provided handles that. It will only change it if it finds exactly 10 numbers in the cell. Otherwise, it will leave the cell "as-is".
Just something else to keep in mind.
Yes, I've noticed this, and am using a work around right now. The VBA version is definitely more elegant. I'm going to have to pass whatever solution I use to others though so I'm less confident about getting to use the VBA solution.
Thank you though!
 
Upvote 0
I'm going to have to pass whatever solution I use to others though so I'm less confident about getting to use the VBA solution.
If you are running on new data files that come in, you can have them save the VBA code to a Personal Macro Workbook. This is VBA code that is available to them whenever they start up Excel on their computer. So then this VBA code would be available to them from EVERY Excel file they open.

Then, there are a few different ways they can run it.
- From the Macro menu
- Assign a keyboard shortcut to it, and use that

I have a special formatting macro that I use on a ton of files, and I use the later option on it. Once set-up, it makes things very quick and easy to run.
 
Upvote 0
If you go the formula route, you can also check to see if the length of the result is at least 1 digit...if it is not then return {blank}. For example:
=IF(LEN(TEXTJOIN("",TRUE,IFERROR(MID(c27,ROW(INDIRECT("1:50")),1)+0,"")))<1,"","+1"&TEXTJOIN("",TRUE,IFERROR(MID(c27,ROW(INDIRECT("1:50")),1)+0,"")))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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