8 Ways to Color a Cell in Microsoft Excel

Adding various shades in the background and borders of Excel cells adds value to your data visualization effort. Read this ultimate Excel tutorial to learn how to color a cell in Excel in easy ways!

You want to make your Excel spreadsheet pop with colors, and I’m here to show you how. Coloring cells in Excel is a handy skill that can help you organize and highlight important data.

Whether you’re a seasoned Excel pro or just starting out, this guide will walk you through the steps to add a splash of color to your spreadsheets. Get ready to learn a quick and easy way to make your data visually appealing. Let’s dive right in!

Coloring Cells in Excel

Microsoft Excel offers extensive customization of its cells. You can color the following cell properties:

Various cell coloring properties
Various cell coloring properties
  • Cell background
  • Cell borders
  • Fonts

Its color options include the following:

  • A standard color wheel
  • A custom color picker
  • RGB and HSL color models
  • Hex color coding

Also read: 6 Ways to Count Colored Cells in Microsoft Excel [Illustrated Guide]

Why Might You Want to Color Cells in Excel?

Find below the reasons to learn the skill of coloring cells in Excel:

  1. Adding shades to cells can make key information stand out, improving readability and making it easier to focus on critical data points within a spreadsheet.
  2. You can use different colors to visually represent trends or patterns in data, helping the audience quickly recognize and analyze important insights.
  3. Color-coded cells can draw your attention to specific data entries. It ensures that you don’t overlook vital information in a sea of numbers and text strings.
  4. You can use cell shading to group together related data sets. This process simplifies data organization and aids in the interpretation of complex spreadsheets.
  5. The use of colors adds visual appeal to Excel documents, making them more engaging and memorable, which can be particularly useful in presentations and reports.
  6. Assigning colors to categories or types of data can help create a visual classification system, aiding in the efficient sorting and filtering of information.
  7. Color coding can simplify complex data analysis tasks by providing visual cues. Such cues guide you through the data, enabling quicker decision-making and insight extraction.

Color a Cell in Excel From the Home Tab

Color tools of Excel
Color tools of Excel

The primary location of the Fill Color, Font Color, and Line Color tools is on the Home tab of the Excel ribbon menu. You’ll find all these command buttons inside the Font commands section.

Coloring a selected range from Fill Color
Coloring a selected range from Fill Color

Here’s how to use these tools to color cells in Excel:

  1. Highlight the cell range for which you need to change the background color or fill color.
  2. Click the Fill Color drop-down menu to choose the color you want.
  3. You can click the More Colors button if you don’t find the shade you’ve been looking for.
  4. Select a color from the Standard or Custom color wheel.
  5. Click OK to apply the color to the selected range.
Changing line color
Changing line color

To change the cell border color, you can click the All Border drop-down arrow and select Line Color from the context menu that opens. You can choose a color for the border lines from the Theme Colors menu or go to the More Colors section.

Color an Excel Cell Using the Right-Click Menu

Change cell color from right click menu
Change cell color from the right-click menu

Find below the steps to change cell color from the right-click menu.

  1. Select the cell or cell range that needs a color upgrade.
  2. Right-click to visualize two context menus.
  3. The one at the top contains annotation tools like font size, Bold, Font Color, Fill Color, etc.
  4. To change the background of the cell, click the Fill Color drop-down menu and choose a color from the Theme Colors or Standard Colors list.
  5. The cell color change will become immediately effective.

Color a Cell in Excel Using Cell Styles

Cell Styles is a list of multiple preconfigured cell color themes you can choose from. This will format the cell background instantly with the chosen color properties.

Location of cell styles commands
Location of Cell Styles commands

On some Excel desktop apps, you should find the Cell Styles menu just beside the Format as Table button inside the Styles commands menu.

Extended cell styles menu
Extended cell styles menu

Click the drop-down arrow to open a full version of the Cell Styles menu.

Cell styles added manually
Cell styles added manually

However, you can add the Cell Styles icon to any of the tabs of Excel from Excel Options > Customize Ribbon menu. For instance, I added this on the Developer tab as shown in the image above.

Using cell styles to color cells in Excel
Using cell styles to color cells in Excel

Coloring Excel cells using Cell Styles is pretty straightforward. Follow these steps:

  1. Select the entire cell range on your worksheet you want to recolor.
  2. Click the Cell Styles button or drop-down arrow.
  3. Choose a theme from the list.
  4. The cell colors will update instantly.

Color Excel Cells Using the Find and Replace Tool

Suppose, you need to color a few cells randomly in the whole worksheet. Instead of manually locating those and applying the chosen color, you can use the Find and Replace tool the following way:

  1. Hit Ctrl + F on your worksheet.
  2. Enter the string or value you want to find.
  3. Click the Replace tab.
  4. Enter the same look-up value in the Replace with field.
  5. Click Format and go to Fill.
  6. Choose a color from the Background Color list and click OK.
  7. Now, click the Replace All button to selectively color specific cells on the whole worksheet.
  8. Excel will replace the values with the same values along with the chosen background color.

Color a Cell Using Format Cells Dialog [Keyboard Shortcut]

Format Cells dialog box has various cell formatting options like Number, Alignment, Font, Border, Protection, including the Fill option.

Various pattern color and styles on format cells
Various pattern color and styles on format cells

If you go to the Fill option, you’ll find various background color options, both solid and pattern colors. There are Pattern Color and Pattern Style buttons allowing you to customize the texture color theme you want to use.

Fill effects for solid colors on Format Cells
Fill effects for solid colors on Format Cells

For solid or fill colors, you can also customize the fill amount by clicking the Fill Effects button.

Coloring Excel cells using Format Cells dialog box
Coloring Excel cells using Format Cells dialog box

To use Format Cells for cell shading in Excel, follow these steps:

  1. Highlight the cell or cell range that you want to recolor.
  2. Press Ctrl + F on the keyboard to launch the Format Cells dialog box.
  3. Select the Fill tab.
  4. Pick any color from the Background Color list.
  5. For more customization, you may click More Colors and Fill Effects.
  6. Once done customizing the background color composition, click OK.
  7. Excel will apply the color you just selected on the Format Cells dialog box.

Color a Cell Using Conditional Formatting Rules

Conditional Formatting lets you color cells or cell ranges based on formulas, values, logic, etc. Suppose, you need to color all cells containing values less than 50 in red. You can do this in an automated way by using rules in conditional formatting.

Format Background Color Based on the Cell Values

More rules Conditional Formatting
More rules Conditional Formatting
  1. Select the dataset or cell range in which you need to programmatically color cells containing a specific value.
  2. Click the Conditional Formatting button on the Styles commands block.
  3. Hover the cursor over the Highlight Cell Rules option.
  4. Click the More Rules option from the overflow menu.
Format only cell that contain
Format only cell that contain
  1. On the New Formatting Rule dialog, select the Format only cells that contain option.
  2. Click the greater than drop-down and choose equal to.
  3. Enter the value you’re looking for. In this example, it’s 28.
  4. Click the Format button and go to the Fill tab.
Fill tab choose color
Fill tab choose color
  1. Choose a color that you want to apply to those cells that contain the number 28.
  2. Click OK.
Applying conditional formatting
Applying conditional formatting
  1. Click OK again to apply the conditional formatting rule.
  2. Excel will instantly recolor the defined cells within the dataset in a shade that you selected when setting up the conditional formatting rule.

Format Background Color of the Cells Using Formula

Conditional formatting allows you to color cells using a formula. Here’s how:

Formatting cell using a formula
Formatting cell using a formula
  1. Highlight your dataset and follow the steps mentioned earlier to reach the New Formatting Rule dialog.
  2. There, select the Use a formula to… option.
  3. Enter your formula into the Format values where this formula is true field.
  4. Now, click Format and choose a fill color.
  5. Click OK twice to apply the formatting on the selected cell range.
Colored blank cells using conditional formatting
Colored blank cells using conditional formatting
  1. Excel will highlight the selected cells automatically, in this case, blank cells.

Automate Cell Coloring Tasks Using Excel VBA

So far, you learned the manual methods to color specific cells in Excel. However, you can automate the process by using Excel VBA. Find below the script you need to use as well as the steps to implement the script.

Sample dataset for VBA
Sample dataset for VBA

In the above dataset, I need to color the cells in column B containing the value 28 in light blue. Also, I must color the cells in column D containing the text string Vegan in light orange.

To solve this, I’ve written the following Excel VBA script:

Sub ApplyConditionalFormatting()
    Dim ws As Worksheet
    Dim dataRange As Range
    Dim rule As FormatCondition
    
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    Set dataRange = ws.Range("A1:D6")
    
    dataRange.FormatConditions.Delete
    
    Set rule = dataRange.Columns("B").FormatConditions.Add(Type:=xlExpression, Formula1:="=ISNUMBER(SEARCH(""28"", B1))")
    rule.Interior.Color = RGB(173, 216, 230)
    
    Set rule = dataRange.Columns("D").FormatConditions.Add(Type:=xlExpression, Formula1:="=ISNUMBER(SEARCH(""vegan"", D1))")
    rule.Interior.Color = RGB(255, 223, 186)
End Sub

To use the above script in a VBA macro, do the following:

Creating a VBA script to color Excel cells
Creating a VBA script to color Excel cells
  1. Press Alt + F11 to bring up the Excel VBA Editor interface.
  2. There, click the Insert button on the VBA menubar.
  3. Choose Module on the context menu that pops up.
  4. Paste the above script into the blank module.
  5. Click Save to save the script.
  6. Click Close to close the Excel VBA Editor.

So far, you’ve successfully created a VBA macro. Here’s how you can run it:

Running a macro
Running a macro
  1. Press Alt + F8 to launch the Macro dialog box.
  2. Choose the ApplyConditionalFormatting macro.
  3. Hit Run to execute the macro.
Colored cells using VBA
Colored cells using VBA

Excel will highlight the selected cells using the defined colors in the VBA script.

Here’s how to modify the above script to make it work on your own worksheet:

  • Replace Sheet1 in the code element "Sheet1" to select on which worksheet you want to run the script.
  • Change the cell range A1:D6 within the code element "A1:D6" according to your own dataset’s complete range.
  • To change the target columns, insert the column number in this code element Columns("B"). For example, Columns("C"), Columns("E"), etc.
  • The formula =ISNUMBER(SEARCH(""28"", B1)) tells Excel how to locate the number 28 in the cells of column B. Here, you can insert your own formula for cell formatting.

📝 Note: Before applying this Excel VBA script in your worksheet, create a backup copy. Any changes made using the code can’t be reversed.

Advanced Automation Using Office Scripts

The automation implemented by Excel VBA has limitations like it’s not available on Excel on the web. Hence, you may want to use Office Scripts to color Excel cells automatically. Office Scripts work on both the Excel for Microsoft 365 desktop and Excel for the web app.

Find below an Office Scripts code and steps to use it:

Using Office Scripts to color cells in Excel
Using Office Scripts to color cells in Excel
  1. Click the Automate tab.
  2. Click on the New Script option.
  3. Copy and paste the following script into the Code Editor that opens on the right.
function main(workbook: ExcelScript.Workbook) {
  
    let currentSheet = workbook.getActiveWorksheet();
    let usedRange = currentSheet.getUsedRange();

    let fill = usedRange.getFormat().getFill();

    fill.setColor("lightyellow");
}
  1. Click the Save script button.
  2. Click the Run button to execute the script.

This Office Scripts code will find the used cell range in your worksheet and format the background cell color in light yellow. If you need a different color, simply type the name without any spaces in this code element: fill.setColor("lightyellow");.

Suppose, you want to apply a specific color to a cell using Office Scripts. To achieve this, you can use the following script:

function main(workbook: ExcelScript.Workbook) {
 
    let cell = workbook.getActiveWorksheet().getRange("A2");

    // Set the fill color to blue.
    cell.getFormat().getFill().setColor("lightblue");
}

Alternatively, use this script to color a specific range using a specific color:

function main(workbook: ExcelScript.Workbook) {
 
    let cell = workbook.getActiveWorksheet().getRange("A2:D6");

    // Set the fill color to blue.
    cell.getFormat().getFill().setColor("lightblue");
}

📝 Note: Office Scripts is only available with a paid Microsoft 365 subscription of Business Standard or better. Also, if you’re using Microsoft 365 account alloted by an organization, the IT admin of that organization must allow Office Scripts to work on your account.

Conclusions

These are all the best and easiest methods to color a cell in Excel. You learned various methods from manual to automatic, including those where you can input custom formulas.

From now on, whether you’re organizing data, creating charts, or making your spreadsheet visually appealing, this skill will come in handy.

Start experimenting with colors to make your data stand out and enhance its clarity.

If you found this article helpful or have any questions, feel free to share your thoughts in the comment box below. Also, don’t hesitate to mention any cool trick you know about coloring Excel cells intuitively.

About the Author

Tamal Das

Tamal Das

I'm a freelance writer at HowToExcel.org. After completing my MS in Science, I joined reputed IT consultancy companies to acquire hands-on knowledge of data analysis and data visualization techniques as a business analyst. Now, I'm a professional freelance content writer for everything Excel and its advanced support tools, like Power Pivot, Power Query, Office Scripts, and Excel VBA. I published many tutorials and how-to articles on Excel for sites like MakeUseOf, AddictiveTips, OnSheets, Technipages, and AppleToolBox. In weekends, I perform in-depth web search to learn the latest tricks and tips of Excel so I can write on these in the weekdays!

Subscribe

Subscribe for awesome Microsoft Excel videos 😃

Related Posts

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get the Latest Microsoft Excel Tips

Follow Us

Follow us to stay up to date with the latest in Microsoft Excel!

Subscribe for awesome Microsoft Excel videos 😃