Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Hemming
 
Posts: n/a
Default adding a formula to a macro


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("444444"&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: http://www.excelforum.com/member.php...o&userid=32185
View this thread: http://www.excelforum.com/showthread...hreadid=520555

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default adding a formula to a macro

Maybe something like:

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range

Set myRng = Selection
myRng.NumberFormat = "[<=9999999]###-####;(###) ###-####"

For Each myCell In myRng.Cells
With myCell
If IsEmpty(myCell.Value) Then
'do nothing
Else
.Value = 444444 & Right(.Text, 4)
End If
End With
Next myCell
End Sub

Hemming wrote:

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("444444"&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: http://www.excelforum.com/member.php...o&userid=32185
View this thread: http://www.excelforum.com/showthread...hreadid=520555


--

Dave Peterson
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
Macro Formula Corey Excel Discussion (Misc queries) 1 February 4th 06 06:13 PM
Adding the contents of a cell to a formula Paul Bond Excel Discussion (Misc queries) 1 January 21st 06 07:19 PM
Adding something to a complicated formula Roz Excel Discussion (Misc queries) 6 December 20th 05 09:00 PM
moving the formula "average" over one column in a macro drumstu Excel Worksheet Functions 1 August 23rd 05 08:01 PM
Help with macro formula and variable Huge project Excel Worksheet Functions 0 December 28th 04 01:27 AM


All times are GMT +1. The time now is 04:06 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"