Returning a Value Based on Text Color

Written by Allen Wyatt (last updated November 26, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


Jose knows he can sort by color in Excel, but wonders if he can use the color of the text within a cell in a formula. For instance, the color of the contents of cell A1 is determined by conditional formatting. In another cell, he'd like to return -1 if A1 is shown in white, 2 if it is black, and 3 if it is blue.

When dealing with conditional formatting, detecting colors applied by the formatting rules can be troublesome. (In other words, it cannot be done reliably across differing versions of Excel.) In this case, it would be much easier to simply recreate, in the formula, the conditional formatting rule and return the values desired. In other words, use the same formulas you used in the conditional formatting rule to determine the value to be returned. You can, if necessary, combine multiple rules into a single formula by wrapping them within an IF statement.

You could even go a step further, if desired. For instance, let's say that you develop a formula that you use in the cells of column B. The formula returns -1, 2, or 3, based on whatever criteria you want to use. Once that formula is in place, you could modify the conditional formatting rules used in column A so that it adjusts text color based upon the values in column B. That way, you aren't dealing with having two sets of formulas for the two columns.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (43) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

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

Turning Off Hyphenation for Individual Words

Word does a semi-decent job when it comes to automatically hyphenating your documents. It even lets you exclude certain ...

Discover More

Getting Rid of Fixed Objects

Some dialog boxes in Excel refer to "fixed objects" in worksheets. What are they and how do you get rid of them?

Discover More

Highlighting the Rows of Selected Cells

If you lose your place on the screen quite often, you might find it helpful to have not just a single cell highlighted, ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Working with Multiple Conditions

When you apply conditional formatting, you are not limited to using a single condition. Indeed, you can set up multiple ...

Discover More

Conditionally Formatting for Multiple Date Comparisons

When you compare dates in a conditional formatting rule, you need to be careful how you put your comparisons together. Do ...

Discover More

Applying Conditional Formatting to Multiple Worksheets

If you just updated your copy of Excel, you may have noticed some differences in how the program handles applying ...

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 two less than 9?

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.