Conditional Formatting With Formulas (10 Examples) - Exceljet
Conditional Formatting With Formulas (10 Examples) - Exceljet
Search... Search
Key functions
Here's the result of the rule applied to the range B4:F8 in
this spreadsheet: IF function
VLOOKUP funct
SUMIFS
function
COUNTIFS
function
INDEX
function
MATCH
Here's the exact formula used: function
SUMPRODUCT
= OR(B4 = "apple",B4 = "kiwi",B4 = "lime") function
Quick start Hi - I'm Da
and I
You can create a formula-based conditional formatting
run
rule in four easy steps:
Exceljet
1. Select the cells you want to format. with my
wife, Lisa. Our goal is
to help you work
faster in Excel. We
create short videos,
and clear examples of
formulas, functions,
pivot tables,
conditional
formatting, and
charts. Read more.
2. Create a conditional formatting rule, and select the
Formula option
Formula logic
Formulas that apply conditional formatting must return
TRUE or FALSE, or numeric equivalents. Here are some
examples:
= ISODD(A1)
= ISNUMBER(A1)
= A1 > 100
= AND(A1 > 100,B1 < 50)
= OR(F1 = "MN",F1 = "WI")
Formula Examples
Below are examples of custom formulas you can use to
apply conditional formatting. Some of these examples
can be created using Excel's built-in presets for
highlighting cells, but custom formulas can go far beyond
presets, as you can see below.
= $F5 = "TX"
The NOW function returns the current date and time. For
details about how this formula, works, see this article:
Highlight dates in the next N days.
= COUNTIF(list,B5) = 0
= B4 >= LARGE(data,input)
Gantt charts
This worksheet uses two rules, one for the bars, and one
for the weekend shading:
This article explains the formula for bars, and this article
explains the formula for weekend shading.
= ISNUMBER(SEARCH($F$2,B2))
Troubleshooting
If you can't get your conditional formatting rules to re
correctly, there's most likely a problem with your
formula. First, make sure you started the formula with an
equals sign (=). If you forget this step, Excel will silently
convert your entire formula to text, rendering it useless.
To x, just remove the double quotes Excel added at
either side and make sure the formula begins with equals
(=).
Dummy Formulas
Limitations
There are some limitations that come with formula-
based conditional formatting. First, You can't apply icons,
color scales, or data bars with a custom formula. You are
limited to standard cell formatting, including number
formats, font, ll color, and border options.
See also
Test conditional formatting with dummy formulas