Hello – I have an excel file with a column of phone numbers. They are formatted 000-000-0000. I need them to have parens around the area code (000) 000-0000. I haven’t found a way to do this by using a special formatting so I think I need to write a macro to iterate through the cells one by one. There are 900 rows, the phone numbers are in column J. Can anyone help me with this macro? Thank you for the assistance.
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Add parens to first 3 numbers of phone number
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Add parens to first 3 numbers of phone number
- This topic has 1 reply, 2 voices, and was last updated 11 years, 3 months ago.
Viewing 0 reply threadsAuthorReplies-
RetiredGeek
AskWoody_MVPJanuary 9, 2014 at 11:11 am #1433027JHA,
You can do this with formatting but you have to eliminate the dashes first.
Place this code in a module.
Code:Option Explicit Sub RemoveDashes() 'Note: Place Excel cursor in the column containing the ' phone numbers before calling. Dim lLastRow As Long Dim lCntr As Long Dim zPN As String Dim lPNCol As Long lPNCol = ActiveCell.Column lLastRow = Cells(Rows.Count, lPNCol).End(xlUp).Row For lCntr = 1 To lLastRow zPN = Cells(lLastRow, lPNCol) zPN = Replace(zPN, "-", "") Cells(lLastRow, lPNCol).Formula = "=" & zPN Next lCntr End Sub
Now place the excel cursor in the column containing your phone numbers and press the Alt+F8.
Select the RemoveDashes line and click Run.
Now format the column like this.
35987-ExcelPhoneNoFmt
HTH :cheers:
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Excel Macro — ask for filename to be saved
by
nhsj
43 minutes ago -
Trying to backup Win 10 computer to iCloud
by
SheltieMom
8 hours, 12 minutes ago -
Windows 11 Insider Preview build 26200.5570 released to DEV
by
joep517
21 hours, 58 minutes ago -
Windows 11 Insider Preview build 26120.3941 (24H2) released to BETA
by
joep517
23 hours, 46 minutes ago -
Windows 11 Insider Preview Build 22635.5305 (23H2) released to BETA
by
joep517
23 hours, 48 minutes ago -
No April cumulative update for Win 11 23H2?
by
Peobody
1 day, 2 hours ago -
AugLoop.All (TEST Augmentation Loop MSIT)
by
LarryK
1 day ago -
Boot Sequence for Dell Optiplex 7070 Tower
by
Serge Carniol
1 day, 15 hours ago -
OTT Upgrade Windows 11 to 24H2 on Unsupported Hardware
by
bbearren
1 day, 18 hours ago -
Inetpub can be tricked
by
Susan Bradley
2 hours, 23 minutes ago -
How merge Outlook 2016 .pst file w/into newly created Outlook 2024 install .pst?
by
Tex265
12 hours, 51 minutes ago -
FBI 2024 Internet Crime Report
by
Alex5723
1 day, 22 hours ago -
Perplexity CEO says its browser will track everything users do online
by
Alex5723
1 day, 10 hours ago -
Login issues with Windows Hello
by
CWBillow
2 days, 9 hours ago -
How to get into a manual setup screen in 2024 Outlook classic?
by
Tex265
1 day, 21 hours ago -
Linux : ARMO rootkit “Curing”
by
Alex5723
2 days, 21 hours ago -
Employee monitoring app leaks 21 million screenshots in real time
by
Alex5723
2 days, 21 hours ago -
Google AI is now hallucinating idioms
by
Alex5723
2 days, 22 hours ago -
april update
by
69800
1 day, 2 hours ago -
Windows 11 Insider Preview build 27842 released to Canary
by
joep517
2 days, 22 hours ago -
Quick Fix for Slowing File Explorer
by
Drcard:))
2 days, 23 hours ago -
WuMgr not loading?
by
LHiggins
1 day, 18 hours ago -
Word crashes when accessing Help
by
CWBillow
5 hours, 48 minutes ago -
New Microsoft Nag — Danger! Danger! sign-in to your Microsoft Account
by
EricB
2 days, 22 hours ago -
Blank Inetpub folder
by
Susan Bradley
2 days, 20 hours ago -
Google : Extended Repair Program for Pixel 7a
by
Alex5723
3 days, 9 hours ago -
Updates seem to have broken Microsoft Edge
by
rebop2020
2 days, 19 hours ago -
Wait command?
by
CWBillow
3 days, 2 hours ago -
Malwarebytes 5 Free version manual platform updates
by
Bob99
3 days, 15 hours ago -
inetpub : Microsoft’s patch for CVE-2025–21204 introduces vulnerability
by
Alex5723
3 days, 22 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.