Yes. In Excel for Microsoft 365 on Windows, you can use a custom RGB color in a conditional formatting rule: open the rule’s Format settings, choose Fill or Font, select More Colors, then enter the red, green, and blue values on the Custom tab. RGB numbers range from 0 to 255; the chosen color is applied whenever the rule’s condition is true.
What RGB means in Excel
RGB is a way to describe a color by combining three amounts of light: red, green, and blue. Each amount is an integer from 0 through 255. A value of 0 means none of that component, while 255 means its maximum. For example, RGB values of 255, 0, 0 describe pure red; 0, 0, 0 is black; and 255, 255, 255 is white.
Excel’s color picker also represents many colors as hexadecimal values. A six-character hex code uses the same components in a different notation: #RRGGBB. Each pair gives one component in red, green, blue order. Thus #00B050 means red 0, green 176, blue 80. It is a green shade, not a special conditional-formatting code. You can convert each pair of hex digits to a decimal number when you need to enter that color into RGB fields.
Conditional formatting changes how a cell looks when a rule is met; it does not change the cell’s stored value. A number can remain 120 while appearing with a green fill, for example. The color is part of the rule’s formatting, so a different user opening the workbook can see the same formatting without the cell value being rewritten.
Set a custom RGB color in a rule
For a typical fill-color rule in Excel for Microsoft 365 on Windows, follow these steps:
- Select the cells the rule should affect.
- Choose Home > Conditional Formatting, then select the type of rule you need, such as Highlight Cells Rules, or choose New Rule.
- Set the condition. For a new rule, select the appropriate rule type and enter its condition.
- Choose Format to open the Format Cells dialog. Select the Fill tab for a background color, or the Font tab for text color.
- Choose More Colors, open the Custom tab if it is available, and enter the Red, Green, and Blue values.
- Confirm the color and rule dialogs, then check a cell where the condition is true.
For example, to make overdue items stand out, you might select a status range, create a rule that identifies the word Overdue, and choose a custom red fill such as RGB 192, 0, 0. The color is a design choice; the rule condition determines which cells receive it. If the selected rule type offers a Format button or a preset formatting style instead, choose New Rule to access more formatting controls.
Excel for Mac has comparable conditional formatting and custom-color controls, although dialog appearance and menu labels can differ by release. In Excel for the web, options and color-picker controls may not match the Windows desktop interface. If you need to enter exact RGB numbers and cannot find those fields in your current version, open the workbook in the desktop app and set the color there.
Choose which cells receive the color
The selected range and the rule’s condition are separate decisions. You might apply a rule to an entire column, a compact data range, or only the cells containing dates. A rule can also use a formula to decide which cells to format, which is useful when the condition depends on another column.
For example, suppose dates are in A2:A20 and you want to shade each date that is earlier than today. Select A2:A20 and create a formula-based conditional formatting rule using this formula:
=A2<TODAY()
The formula is written for the top-left cell in the selected range. Excel adjusts the relative reference for the other rows, so A3 is evaluated for the next row, then A4, and so on. Choose the desired RGB fill in the rule’s Format settings. If blank cells should not be highlighted, use this formula instead:
=AND(A2<>"",A2<TODAY())
This version requires the cell to be nonblank as well as earlier than today. If your dates are stored as text rather than valid Excel dates, the comparison may not behave as intended; correcting the underlying data is usually better than trying to solve that issue with a color choice.
What conditional formatting can color
A conditional formatting rule can control more than a cell’s background. Depending on the rule and dialog options, you can set a font color, apply bold or other font effects, and add borders. Choose a color that makes the condition easy to recognize, but keep the formatting restrained enough that the worksheet remains readable.
Color scales, data bars, and icon sets work differently from a simple fill rule. A color scale maps values to a range of colors, while data bars and icon sets provide visual comparisons within a range. Their settings let you choose colors or visual styles, but they are not the same as entering one RGB fill for a single true-or-false condition. A scale is useful for showing a gradient across values; a single custom fill is clearer when a specific threshold matters.
Conditional formatting colors can also interact with ordinary cell formatting. If a cell already has a manually applied fill, the conditional format may visually take precedence while its rule applies. When the condition stops being true, the cell’s underlying manual formatting can show again. This is why a cell may appear to keep a color even after its conditional formatting condition is no longer met.
Can a formula return an RGB color?
In standard conditional formatting, a worksheet formula determines whether a rule applies; it does not return a color value that Excel then turns into a fill. You can use formulas to make the condition dynamic, and you can choose a custom RGB color for the rule’s format, but that selected color is fixed in the rule.
If you need different colors for different conditions, create multiple rules, each with its own condition and formatting. For example, one rule could flag values below a target with a red fill, while another flags values meeting the target with green. Review the order of rules in Home > Conditional Formatting > Manage Rules, especially if rules overlap or if a rule is set to stop evaluation of later rules.
For a continuous value-to-color effect, use a color scale rather than trying to make a formula output an RGB code. For automation beyond the built-in rule options, VBA can set formatting, but macros add maintenance and security considerations. A macro is not necessary for ordinary threshold highlighting, and conditional formatting rules are usually easier for other workbook users to inspect.
RGB, hex, and theme colors compared
RGB is convenient when a brand guide or design specification gives three decimal values. Hex is common in web design and design tools, and can be converted component by component. Theme colors are tied to the workbook’s theme, which can make them easier to coordinate across charts, shapes, and cells.
- RGB: Use three values, such as 32, 96, 160, when the exact decimal components are known.
- Hex: Use a code such as #2060A0 in a tool that accepts hex, then convert 20, 60, and A0 from hexadecimal to decimal if Excel asks for RGB.
- Theme color: Choose a theme swatch when you want the workbook’s theme palette and theme changes to guide the appearance.
Hex notation normally includes the leading # in design applications, but Excel’s RGB fields expect separate numeric components rather than the full hex string. Do not paste #2060A0 into a field that asks for a red number. Also remember that a theme swatch may look similar to a custom RGB shade without being exactly the same color.
Find and fix color problems
If a color does not appear, first check whether the rule condition is true for the cells you are looking at. Then select one of those cells and open Home > Conditional Formatting > Manage Rules. Check whether the rule applies to the intended range, whether another rule takes precedence, and whether the rule’s formula uses the correct relative or absolute references.
Common causes include selecting the wrong range before creating the rule, applying a formula that refers to the wrong row, or typing RGB components in the wrong order. The sequence is red, green, blue. For instance, entering 0, 0, 255 gives blue, whereas 255, 0, 0 gives red. If you copied a value from a hex color picker, convert each pair separately rather than treating the six digits as one number.
Another issue is contrast. A light font on a light fill, or a dark font on a dark fill, can make data difficult to read. Check the rule on actual worksheet values and consider how it will look when printed or viewed on a different screen. Avoid using color as the only signal for an important status: add a text label, icon, or clear heading so the meaning is still understandable for readers who cannot distinguish the colors.
If the conditional format is correct but you want the cell to return to its usual appearance when the condition is false, inspect the cell’s ordinary formatting too. Conditional formatting does not necessarily erase a manually assigned fill. Clear or adjust the manual format only if that is the intended design, and preserve a copy of important workbook formatting before making broad changes.
Frequently Asked Questions
Can I type a hex code directly into Excel conditional formatting?
Usually, the custom-color dialog asks for separate red, green, and blue values rather than a complete #RRGGBB string. Convert each two-character hex pair to decimal, then enter the three numbers in RGB order.
Does Excel support custom RGB colors in conditional formatting?
Yes. In the desktop Windows app, choose the rule’s Format options and use More Colors to enter custom RGB components. The precise dialog appearance may vary across Excel versions and platforms.
Can conditional formatting change to a different RGB color for every value?
A standard rule’s chosen fill color is fixed. Use a color scale for a gradient, or create multiple rules for distinct conditions. A worksheet formula alone cannot return an arbitrary fill color.
Why does my conditional formatting color not show?
Check that the condition is true, the Applies to range is correct, and no other rule is affecting the same cells. Also check formula references and text-versus-number mismatches in the source data.
Do RGB colors change the cell value?
No. Conditional formatting changes visual presentation, not the stored value. A date, number, or text entry remains the same even while a rule displays a custom fill, font, or other format.
Related
- Copy Paste in Excel: Keep Column Widths When Pasting
- Copy an Entire Excel Spreadsheet to a New File
- Copy and Paste X Times in Excel: Repeat Cells or Rows
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Remove Leading Zeros from Text Without Data LossTo remove leading zero characters from text in Excel, use a formula in B2 and fill it down:…
- Remove Spaces in an Excel Column: Step-by-StepTo remove every ordinary space from a column in Excel, select the column or range, press Ctrl+H, enter…
- Excel Custom Number Format for MillionsYes. In Excel for Microsoft 365 on Windows, select the cells, press Ctrl+1, choose Custom, and enter #,##0.0,,"M".…
- Excel Shortcut to Insert a Row and Shift Cells DownIn Excel for Microsoft 365 on Windows, select the cell where the new space should begin and press…
- How to Make Two Columns in a Word Document QuicklyTo make two columns in Microsoft Word for Microsoft 365 on Windows, select the text you want to…
- Google Sheets: How to Freeze the Top Two Rows on ScreenTo freeze the top two rows in Google Sheets, open the spreadsheet in a web browser and choose…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.