Custom Format for Phone Nmuber with Letters

dcoledc

Active Member
Joined
May 6, 2010
Messages
403
Does anyone know how to code a custom format for a phone number with letters in it?

I am currently using this code for phone numbers in general.
Code:
With Selection
    .NumberFormat = "[<=9999999]###-####;(###) ###-####"
End With

It the user enters a number, such as 770789HELP, it will not format. I want this to format like so: (770) 789-HELP

Any thoughts?
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

machopicho

Well-known Member
Joined
Feb 28, 2010
Messages
606
i didn't use number format to obtaine the result that you want, but considering as works this string:
Code:
.NumberFormat = "[<=9999999]###-####;(###) ###-####"
i wrote this macro:
Code:
Sub FormatNumberPhone()
ls = Len(Range("A1"))
For i = 1 To ls
If IsNumeric(Mid(Range("A1"), i, 1)) Then
num = num & Mid(Range("A1"), i, 1)
End If
Next
lnn = Len(num)
lt = ls - lnn
numstr = "(" & Left(num, lnn - 7) & ")" & " " & Mid(num, lnn - 6, 3) & "-" & Right(num, 4)
Range("A1") = numstr & Right(Range("A1"), lt)
End Sub
Try it with string in A1!
 

dcoledc

Active Member
Joined
May 6, 2010
Messages
403
Wow, that's some serious coding. Unfortunately, my version of excel seems to have problems with Left, Right, etc. coding. I plan on upgrading soon. Thanks for giving it a shot, perhaps someone else will be able to use it. Someone whose Excel works properly.

I had the same problem with coding someone provided to check to see if a file is open.

Take Care

P.S. I will save this for when I get a new computer and update in Excel
 

Watch MrExcel Video

Forum statistics

Threads
1,123,482
Messages
5,601,920
Members
414,482
Latest member
morkar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top