View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pete_UK
 
Posts: n/a
Default How can I automatically add an area code to a number in a cell

In a blank column (let's assume this is column AM), enter this into
cell AM2:

=IF(LEFT(AE2,1)="(","1-"&MID(AE2,2,3)&"-"&RIGHT(AE2,8),"1-585-"&AE2)

and copy down to AM2500. This assumes the phone numbers are in the two
formats described, and works by examining the first character of the
number - if it is "(", as in "(716) 555-1212", this will be converted
to "1-716-555-1212", otherwise it will have "1-585-" appended to the
beginning of it.

If you want these converted numbers to replace the ones you have, then
highlight the cells AM2:AM2500, click <copy, then Edit | Paste Special
| Values (check) | OK then <Enter - this will have fixed the values in
column AM. You could then <cut these values and <paste them to
overwrite the values in column AE.

Hope this helps.

Pete