I have a column of telephone numbers. I need to change the area code and
first three digits of the number to a new area code and new first three
digits. I need to do this for the entire column. example: 5555555555
change to (444)444-5555. the only part of the number that will stay the
same is the last 4 digits. if there are 100 different telephone numbers
there will be 100 unique last 4 digits. the formula
=value(quot;444444quot;amp;right(a1:a100,4)) works well as a formula and changing
the cell format to special, telephone number , but I really wanted to
use in a marco. can anyone help .....thanks--
Hemming
------------------------------------------------------------------------
Hemming's Profile: www.excelforum.com/member.php...oamp;userid=32185
View this thread: www.excelforum.com/showthread...hreadid=520555Maybe something like:
Option Explicit
Sub testme()
Dim myRng As Range
Dim myCell As Range
Set myRng = Selection
myRng.NumberFormat = quot;[lt;=9999999]###-####;(###) ###-####quot;
For Each myCell In myRng.Cells
With myCell
If IsEmpty(myCell.Value) Then
'do nothing
Else
.Value = 444444 amp; Right(.Text, 4)
End If
End With
Next myCell
End Sub
Hemming wrote:
gt;
gt; I have a column of telephone numbers. I need to change the area code and
gt; first three digits of the number to a new area code and new first three
gt; digits. I need to do this for the entire column. example: 5555555555
gt; change to (444)444-5555. the only part of the number that will stay the
gt; same is the last 4 digits. if there are 100 different telephone numbers
gt; there will be 100 unique last 4 digits. the formula
gt; =value(quot;444444quot;amp;right(a1:a100,4)) works well as a formula and changing
gt; the cell format to special, telephone number , but I really wanted to
gt; use in a marco. can anyone help .....thanks
gt;
gt; --
gt; Hemming
gt; ------------------------------------------------------------------------
gt; Hemming's Profile: www.excelforum.com/member.php...oamp;userid=32185
gt; View this thread: www.excelforum.com/showthread...hreadid=520555
--
Dave Peterson
- Jun 22 Fri 2007 20:38
adding a formula to a macro
close
全站熱搜
留言列表
發表留言