excel2007.Tips.Net Welcome toExcel2007.Tips.Net

Helpful Links

Excel 2007 Home
Tips.Net Home

Ask a Question
Make a Comment

Family Tips
Gardening Tips
Money Tips
Wedding Tips

Newest Tips

Changing a Link's Source

Using Conditional Formatting to Shade Rows

Editing by Moving and Copying

Making Sure Duplicate Names Aren't Entered

Applying a Conditional Format to a Full Row

Hiding Worksheet Tabs

Making Cells Flash

 

Using Conditional Formatting to Check for Data Type

Summary: Conditional formatting can be used to highlight cells that contain the improper type of data for your needs. This tip examines how to check if either text or numbers have been entered into a cell.

Joshua is trying to establish a conditional format that will alert a user that text data has been entered into a cell intended for numerical data or when numerical data has been input into a cell intended for text data.

A conditional format can be used to draw attention to when an improper value (text or numeric) has been entered in a cell, but a more robust approach might be to prohibit the improper value from being entered in the first place. This can be done with the data validation capabilities of Excel. These capabilities have been discussed, in detail, in other ExcelTips; more information can be found here:

http://excel.tips.net/E165_Data_Validation.html

Using data validation you can specify the type and range of data permitted in a cell, along with how stringently you want that specification followed. If you prefer to not use data validation for some reason, you can set up a conditional format that will verify if the information placed in a cell is of the data type you want. Follow these steps:

  1. Select the cells that you want conditionally formatted.
  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. Choose Highlight Cells Rules and then choose More Rules from the resulting submenu. Excel displays the New Formatting Rule dialog box. (Click here to see a related figure.)
  4. In the Select a Rule Type area at the top of the dialog box, choose Use a Formula to Determine Which Cells to Format.
  5. In the Format Values Where This Formula Is True box, enter one of the following formulas. (The first is if you want to highlight the cell if it contains text; the second if it contains a number. Make sure you replace A1 with the cell address of the cell in the upper-left corner of the range selected in step 1.)
  6.      =ISTEXT(A1)
         =ISNUMBER(A1)
    
  7. Click Format to display the Format Cells dialog box.
  8. Using the controls in the dialog box, specify a format that you want used for those cells selected in step 1. For instance, you may want bold text in a red typeface.
  9. 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.
  10. Click OK.

Related Tips:

Take Control! Master the real power behind Word! Successfully master the secrets of powerful formatting and create documents that stand out from the rest. Best of all, you can create documents that are easy to maintain and quick to change. Check out WordTips: Styles and Templates today!