Excel formula to alter cell's background color but keep its current value?

You didn't tag with your Excel version or provide any sample data, so let's say you are using Excel 2007 or greater, and your worksheet looks like this:

enter image description here

To compare the cells in column D to the corresponding cells in column A, do the following:

  1. Select cells D2:D7 by clicking on cell D2 and then dragging down to cell D7, so that cell D2 is the Active Cell (as seen in the above screenshot)
  2. On the Ribbon, click Home -> Conditional Formatting -> New Rule...
  3. In the Select a Rule Type section of the New Formatting Rule dialog, click Use a formula to determine which cells to format
  4. In the Format values where this formula is true textbox, enter the following formula: =D2<>A2
  5. Click the Format button
  6. In the Format Cells dialog, set your desired formatting (e.g. click the Fill tab, and select the Yellow color)
  7. Click the OK button
  8. In the New Formatting Rule dialog, click the OK button
  9. Repeat the above steps, except select cells E2:E7, and use the formula =E2<>B2


Note:
Since the columns I am formatting are contiguous, I could have simply selected cells D2:E7 instead of D2:D7, and then skipped step 9. However, I am assuming that the columns you want to format are not necessarily contiguous.


Optional:
Since background-color formatting hides cell gridlines, one additional thing I like to do in the Format Cells dialog is to click the Border tab, select "White, Background 1, Darker 15%" in the Color dropdown, and then apply that color to the Outline borders. That way, your formatted cells will appear to retain their gridlines.


Result:

enter image description here