View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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