LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Formatting Macro Issue

The following code reformats phone numbers from "(123) 456-7890" to
"123-456-7890". The macro performs this function perfectly, but the issue is
that it overwrites all strings in the list with the first string in the list.

Example: The macro changes the following list from...
(123) 456-7890
(234) 567-8901
(345) 678-9012
(456) 789-0123
To...
123-456-7890
123-456-7890
123-456-7890
123-456-7890

Here's the code I'm using:

Sub ReplaceParentesesWithDash()
Application.ScreenUpdating = False
Dim cell As Range
Set r = Selection
For Each cell In r
v = cell.Text
v = Replace(v, "(", "")
v = Replace(v, ")", "")
v = Replace(v, " ", "")
v = Replace(v, "-", "")
v = Left(v, 3) & "-" & Mid(v, 4, 3) & "-" & Right(v, 4)
r.Value = v
Next cell
Application.ScreenUpdating = True
End Sub

Thank you.
Exceller
 
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
Formatting issue Iriemon Excel Worksheet Functions 2 February 24th 10 03:23 PM
Formatting Issue Mike Excel Discussion (Misc queries) 3 June 18th 09 12:38 AM
Formatting issue [email protected] Excel Programming 2 April 6th 07 03:55 PM
Macro + Dates formatting issue John Excel Programming 2 August 23rd 06 09:04 AM
formatting issue scrabtree[_2_] Excel Programming 2 August 5th 04 01:52 PM


All times are GMT +1. The time now is 08:22 AM.

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"