Software

Use Excel's conditional formatting features to highlight input cells

Conditional formatting is great for adding visual clues to values, but you can also use it to identify input cells to guide users through a data entry task.

You probably use conditional formatting to highlight specific values in a conditional way. For instance, if a value is less than 0, you might want to display that value in red. You can also use conditional formatting to highlight a range of input cells - it's simple and the result is an easy-to-implement data entry guide.

The following sheet shows a simple savings calculator that uses conditional formatting to highlight the input cells for each savings option. The user selects a savings options from the list and conditional formatting highlights the input cells. Those cells remain highlighted until the user selects a different savings option from the list. The formulas above the input area display the appropriate savings result.

Before we get started, you should know that this example is about using conditional formatting to highlight input cells. It is not about the savings formulas or the other pieces used to round out this example. In fact, you don't have to enter the formulas at all to get this technique to work. There are a number of ways to enhance this sheet further if your goal is to build a savings calculator. For instance, a finished sheet might display only the relevant results (column B in the upper portion). In addition, I based the data validation list on the static list in the upper part of the sheet. You might not want to display that list in the actual data entry portion. For the sake of explanation and simplicity, I chose to put everything on the same sheet.

Now, let's get started! To build the sheet, do the following:

  1. Use the sheet below (which still displays gridlines) as a guide to entering all the labels.
  2. Next, define the following names: B6 Rate C6 YSave D6 MSave E6 OTSave F6 Deposit G6 Goal
  3. Enter the following formulas B2 =IFERROR(FV(Rate/12,YSave*12,-MSave,-Deposit),"Error") B3 =IFERROR(FV(Rate,YSave,0,-OTSave),"Error") B4 =IFERROR(PMT(Rate/12,YSave*12,-Deposit,Goal),0)

At this point, your sheet should resemble the one below. You might want to apply the currency format to B2:B4 and D6:G6. I also shaded and outlined a few label cells. (These formatting steps aren't necessary for the technique to work.) Now you're ready to build the list that offers savings options.

  1. Select A6.
  2. Click the Data tab.
  3. In the Data Tools group, click the Data Validation dropdown.
  4. Choose Data Validation. In Excel 2003, choose Validation from the Data menu.
  5. In the resulting dialog box, choose List from the Allow dropdown.
  6. Enter =$A$2:$A$4 in the source control and click OK.

The next step is to add the conditional formatting that highlights the input cells for each savings option. To do so for the first savings option, Future Value (Monthly), do the following:

  1. Select cells B6:D6 and F6.
  2. Click the Home tab.
  3. In the Styles group, click the Conditional Formatting dropdown. In Excel 2003, choose Conditional Formatting from the Format menu.
  4. Choose New Rule. (Skip this step in Excel 2003.)
  5. Select the Use A Formula To Determine Which Cells To Format option in the Select A Rule Type section. In Excel 2003, choose Formula Is from the Condition 1 dropdown.
  6. In the Format Values Where This Formula Is True control, enter the formula: =$A6="Future Value (Monthly)".
  7. Click Format.
  8. Choose a color from the Fill tab and click OK.
  9. Click OK to return to the sheet.

Repeat the steps above to set the conditional formatting for the other two savings options:

  • Future Value (One-Time) uses input cells B6:C6 and E6 and the conditional formula, =$A6="Future Value (One-Time)".
  • Savings Goal uses input cells B6:C6, F6:G6 and the conditional formula, =$A6="Savings Goal".

If you like, you can turn off the gridlines by clicking the Page Layout tab and unchecking the View option under Gridlines in the Sheet Options group. At this point, your sheet should resemble the first sheet shown above, which highlights the input cells for the third savings option, Savings Goal.

To guide data entry for the first option, Future Value (Monthly), choose that option from the validation list. As you can see below, doing so highlights a different set of input cells. Choose Future Value (One-time) to change the input cells to accommodate that savings option.

Remember, you can further enhance this sheet as an actual savings calculator. You might want to use different (more precise) formulas, or add more savings options and input values. You'd probably want to apply validation rules for the input cells and protect the formula and label cells. In addition, you should probably delete input values when changing options. They won't interfere with the formulas if you leave them, but they might confuse users.

The sheet, as is, illustrates how to use conditional formatting to highlight input cells. It doesn't complete the savings calculator as a useable product.

I'd like to hear how you put this particular tip to use—it's interesting, easy, and has a world of possible uses!

About

Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.

9 comments
landsend3
landsend3

Is there a way to conditionally format the color of the worksheet tab based upon a formula on the sheet? E.g. I would like to color the tab green if each of five cells have the value "Y" in them.

gkitts
gkitts

Susan you're the best. I look forward to every article you pen and they have helped me immeasurably. Thanks and keep up the great work.

char49
char49

I really like the Excel tips and would like to print them, but I get an error report. Any solution?

Nstig8r
Nstig8r

I found this how-to ideal for my needs. Thank you very much! Now, if only there was a way to sum the number of highlighted cells of each color... # of red cells ='s... # of green cells ='s... Hmmmmm

dorislinux
dorislinux

I agree with tolmr - always gaining something on this site. Always very helpful tips to know. Thank you so much!!!!

jlmccabes
jlmccabes

WOW - I never thought of that way of doing it. Easier and the colors guide the user to input those fields necessary. Much easier for the input of data to see where it goes - in what cell. Thank You for that one.

tolmr
tolmr

I have rarely come away from this site without gaining something... excellent tip

ssharkins
ssharkins

Share more details and let's see what we can come up with!

Editor's Picks