Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add area code to phone numbers in ranges


I have a worksheet that has telephone numbers in two seperate columns.
I'd like to locate all the 7-digit numbers (those without area codes)
in both columns and then add a specific area code to all those numbers.
Any number encountered that already has 10 digits I'd like to ignore and
leave alone.


--
JimDandy
------------------------------------------------------------------------
JimDandy's Profile: http://www.excelforum.com/member.php...o&userid=16578
View this thread: http://www.excelforum.com/showthread...hreadid=514634

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add area code to phone numbers in ranges


asumptions:
#'s in column a starting row 1
7 digit numbers are of from xyz-abcd (length is 8)

in an empty column, row:

=if(len(a1)8,a1,"(xxx) "&a1) where xxx is the area code

copy down, then change to values and then overlay original data


--
duane


------------------------------------------------------------------------
duane's Profile: http://www.excelforum.com/member.php...o&userid=11624
View this thread: http://www.excelforum.com/showthread...hreadid=514634

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add area code to phone numbers in ranges

Dim i as long, j as long, rng as Ragne
Dim cell as Range, v as Variant
v = array(10,15)
for j = lbound(v) to ubound(v)
i = v(j)
set rng = Range(cells(1,i),cells(1,i).End(xldown))
for each cell in rng
if len(cell.Value) = 7 then
cell.value = "456" & cstr(cell.Value)
end if
Next rng
Next j

If your columns are adjacent, then it could be simpler. Change 10 and 15
to indicate your columns.

--
Regards,
Tom Ogilvy

"JimDandy" wrote in
message ...

I have a worksheet that has telephone numbers in two seperate columns.
I'd like to locate all the 7-digit numbers (those without area codes)
in both columns and then add a specific area code to all those numbers.
Any number encountered that already has 10 digits I'd like to ignore and
leave alone.


--
JimDandy
------------------------------------------------------------------------
JimDandy's Profile:

http://www.excelforum.com/member.php...o&userid=16578
View this thread: http://www.excelforum.com/showthread...hreadid=514634



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding area codes only to phone numbers missing an area code RC Excel Discussion (Misc queries) 5 May 3rd 23 05:06 PM
Deleting the area code on excel spread sheet phone numbers?? Ben Excel Discussion (Misc queries) 4 October 3rd 07 01:34 PM
adding a phone area code that is not there Kelly Excel Discussion (Misc queries) 4 December 13th 06 12:15 AM
How do I add an area code to a list of phone numbers in Excel? PPuser Excel Worksheet Functions 2 April 5th 05 08:35 PM
Adding Area Code To Phone Numbers Minitman[_4_] Excel Programming 2 May 21st 04 05:43 PM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"