Loading
ExcelTips (Menu Interface)

# Converting Phone Numbers

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Converting Phone Numbers.

We have all seen the ads on TV: "Call 1-800-GET THIS for your set of super-sharp knives." You may be faced with the need to convert phone numbers from the text version (as shown on the ads) to the numbers represented by that text. The following macro, DoPhone, will perform the conversion magic for you:

```Sub DoPhone()
Dim rngSrc As Range
Dim lMax As Long, lCtr As Long
Dim J As Integer
Dim Phone As String, Digit As String

Set rngSrc = ActiveSheet.Range(ActiveWindow.Selection.Address)
lMax = rngSrc.Cells.Count

For lCtr = 1 To lMax
If Not rngSrc.Cells(lCtr).HasFormula Then
Phone = rngSrc.Cells(lCtr).Value
For J = 1 To Len(Phone)
Digit = Ucase(Mid(Phone, J, 1))
Select Case Digit
Case "A" To "P"
Digit = Chr((Asc(Digit) + 1) \ 3 + 28)
Case "Q"
Digit = "7"     'May want to change
Case "R" To "Y"
Digit = Chr(Asc(Digit) \ 3 + 28)
Case "Z"
Digit = "9"     'May want to change
End Select
Mid(Phone, J, 1) = Digit
Next J
rngSrc.Cells(lCtr).Value = Phone
End If
Next lCtr
End Sub
```

The DoPhone procedure tries to convert the information in any cell that does not contain a formula. All you need to do is select the cell (or cells) you want to convert, and then run the procedure. The result is that any text in the cells are converted to their digit equivalents on a phone. Thus, 598-Tips becomes 598-8477.

You should note one small peculiarity of DoPhone, and you may want to change it. Some phones recognize the letters Q and Z as the digits 7 and 9, respectively. Others simply leave these digits out, or they are converted to 0. DoPhone, as written here, converts these letters to 7 and 9. You can change the appropriate places in the Select Case structure, as desired, so they are changed to numbers according to your needs. (The appropriate places are commented in the listing.)

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2269) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Converting Phone Numbers.

Related Tips:

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

### Leave your own comment:

 *Name: Email: Notify me about new comments ONLY FOR THIS TIP Notify me about new comments ANYWHERE ON THIS SITE Hide my email address *Text: *What is 5+3 (To prevent automated submissions and spam.)

### Comments for this tip:

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)

# Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

Advertise with Us

Our Privacy Policy

# Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

# Our Products

Helpful E-books

Newsletter Archives

Excel Products

Word Products

# Our Authors

Author Index

Write for Tips.Net

Copyright © 2017 Sharon Parq Associates, Inc.