Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Conditional Formatting for Errant Phone Numbers.

Conditional Formatting for Errant Phone Numbers

Written by Allen Wyatt (last updated May 26, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021


If you use Excel to store a list of phone numbers, you may want a way to determine if any of the phone numbers in your list are outside of a specific range. For instance, for your area, only phone numbers in the 240 exchange (those beginning with 240) may be local calls. You might want to highlight all the phone numbers in the list that do not begin with 240, and therefore would be long distance.

The way that you do this depends on whether your phone numbers are stored as text or as formatted numbers. If you enter a phone number with dashes, periods, parentheses, or other non-numeric characters, then the phone number is considered a text entry. If you format the cells as phone numbers (Format Cells dialog box | Number tab | Special | Phone Number), then the phone number is considered a number and formatted for display by Excel.

If your phone numbers are text entries, then use these steps to apply the desired conditional formatting:

  1. Select the cells containing the phone numbers. (For the sake of this example, I assume that the first cell you select is A3.)
  2. With the Home tab of the ribbon displayed, click the Conditional Formatting option in the Styles group. Excel displays a palette of options related to conditional formatting.
  3. Click New Rule. Excel displays the New Formatting Rule dialog box. (See Figure 1.)
  4. Figure 1. The New Formatting Rule dialog box.

  5. In the Select a Rule Type area at the top of the dialog box, choose Use a Formula to Determine Which Cells to Format.
  6. In the Format Values Where This Formula Is True box, enter the following formula, replacing A3 with the address of the active cell selected in step 1:
  7.      =LEFT(A3,3)<>"240"
    
  8. Click Format to display the Format Cells dialog box.
  9. Set the formatting options to highlight the errant phone numbers, as desired.
  10. Click OK to dismiss the Format Cells dialog box. The formatting you specified in step 7 should now appear in the preview area for the rule.
  11. Click OK.

These steps will even work if the phone numbers are numeric, but you may want to use a different approach if the phone numbers were entered as numbers. The following steps will work:

  1. Select the cells containing the phone numbers. (For the sake of this example, I assume that the first cell you select is A3.)
  2. With the Home tab of the ruler displayed, click the Conditional Formatting option in the Styles group. Excel displays a palette of options related to conditional formatting.
  3. Click New Rule. Excel displays the New Formatting Rule dialog box.
  4. In the Select a Rule Type area at the top of the dialog box, choose Format Only Cells That Contain. The left portion of the rule description should automatically be set to Cell Value.
  5. Use the next drop-down list in the rule description to choose Not Between.
  6. Set the lower and upper boundaries of the condition to 2400000 and 2409999, respectively. (You are specifying that the condition is met if the number is not between 2400000 and 2409999, which is the range of acceptable phone numbers.) (See Figure 2.)
  7. Figure 2. The New Formatting Rule dialog box.

  8. Click Format to display the Format Cells dialog box.
  9. Set the formatting options to highlight the errant phone numbers, as desired.
  10. Click OK to dismiss the Format Cells dialog box. The formatting you specified in step 8 should now appear in the preview area for the condition.
  11. Click OK.

If you want to convert your textual phone numbers to numeric phone numbers, so that you can use this last method of conditional formatting, you need to "clean up" your list of numbers. In other words, you need to remove all non-numeric characters from the phone numbers. You can do this using Find and Replace to repeatedly remove each non-numeric character, such as dashes, periods, parentheses, etc. Once the phone numbers are clean, you can format them as phone numbers (using the Format Cells sequence mentioned earlier in this tip) and use the conditional formatting just described.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6178) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Excel here: Conditional Formatting for Errant Phone Numbers.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Why Should I Upgrade?

As new versions of software are released, users are perpetually faced with the decision of whether to upgrade their ...

Discover More

WordTips: The Macros (Special Offer)

WordTips: The Macros can help you discover the power and capabilities of macros within the word environment. ...

Discover More

Wielding the Power

If you are done using Windows for a while, it is a good idea to shut down your system. Windows provides several different ...

Discover More

Dive Deep into Macros! Make Excel do things you thought were impossible, discover techniques you won't find anywhere else, and create powerful automated reports. Bill Jelen and Tracy Syrstad help you instantly visualize information to make it actionable. You’ll find step-by-step instructions, real-world case studies, and 50 workbooks packed with examples and solutions. Check out Microsoft Excel 2019 VBA and Macros today!

More ExcelTips (ribbon)

Conditional Formats that Distinguish Blanks and Zeroes

Conditional formatting is a great tool. You may need to use this tool to tell the difference between cells that are empty ...

Discover More

Turning a Cell Red when a Threshold is Exceeded

Excel provides a great conditional formatting capability that allows you to change how a cell appears based on critiera ...

Discover More

Highlighting Cells Containing Specific Text

If you want to highlight cells that contain certain characters, you can use the conditional formatting features of Excel ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 9 + 5?

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


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.