Link to home
Start Free TrialLog in
Avatar of dan9591
dan9591

asked on

Excel 2010 phone number prefix formula macro

I thought I was pretty good with excel formulas until someone asked me for this one!

I have a list of phone numbers in a spreadsheet. They are all in number only format: xxxxxxxxxx. No parentheses, dashes, spaces, etc.

What I need to do is put a prefix with the number “1” for every line EXCLUDING some specific area codes. For example:

661726XXXX
707651XXXX
714572XXXX
808432XXXX
818719XXXX
909427XXXX
954932XXXX
305932XXXX
561353XXXX
786353XXXX

Only the first six rows should have a 1 prefix. When I am done, it needs to look like this:

1661726XXXX
1707651XXXX
1714572XXXX
1808432XXXX
1818719XXXX
1909427XXXX
954932XXXX
305932XXXX
561353XXXX
786353XXXX

Obviously the following area codes are local and therefore do not require a 1 by the auto dialer: 954, 305, 561, 786. More may be added later, so I also need a way to modify the exclusion list.

Yes, I know I could easily sort the list and run a concatenate formula, but the list is huge and is updated daily. I need to make this a macro that can be run daily by an end user… someone absolutely oblivious to excel formulas… I would rather it be a macro than a VBA script, if possible.

BYW – this is not for spamming or debt collections, it’s strictly for “good” purposes!

Thanks in advance!!!
Avatar of Dave
Dave
Flag of Australia image

> What I need to do is put a prefix with the number “1” for every line EXCLUDING some specific area code

A sample showing your spreadsheet layout, with the excluded list will help us tailor an answer

Cheers

Dave
Avatar of dan9591
dan9591

ASKER

Check out the before and after samples I posted in the question. The last 4 are excluded. They are: 305, 954, 561 and 786.
ASKER CERTIFIED SOLUTION
Avatar of Dave
Dave
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
For consistency's sake, why do you omit the "1" for local numbers.  We dial all numbers with 1+ten-digit, or the PBX will add the 1 for us.  Even numbers in our own area code, which could for simplicity be dialed with just 7-digit.

If this is for an auto-dialer, then you're not saving any labor cost on dialing, but you're adding labor cost to process the list.  Plus, if you ever have to share the list with another call center or branch of your business, the numbers will be formatted incorrectly.
Avatar of dan9591

ASKER


brettdj-That’s a great article! I thought about an array, but the best I could do with it is replacing data. For instance replacing 707 with 1707. The problem was when there a 707 elsewhere in the phone number. 7072227072 turned into 170722217072... is there a way to run it on just the first three digits in a cell?

aleghart - That was the first question I asked! It seems their auto dialer system has a problem with the 1. They are working on this issue separately, but it may be a while until they get it resolved, so they decided to try to tackle the issue on 2 fronts.

> is there a way to run it on just the first three digits in a cell?

Thats what my actual code does above :)

1) I add a 1 to all cells
2) Then take off the 1 if the 2 to 4 character string matches an exclsuion code

The article link was for background on the array/range read write

Cheers

Dave
Avatar of dan9591

ASKER

Dave- Sorry, I was responding on my blackberry and did not see the code. I tested it out this morning and it works perfectly. Brilliant! Thanks a lot!!!
Avatar of dan9591

ASKER

Brilliant!