How to Color a Bar Chart by Category in Excel (2 Methods)

Dataset Overview

Suppose we have a math exam mark list for some students, with their names in column B and their scores in column C. Our goal is to classify these scores into specific categories (0-64, 65-79, 80-89, and 90-100) and create a bar chart with colored bars representing these categories. Let’s explore two methods to achieve this:

Excel Bar Chart Color by Category


Method 1 – Using the IF Function

  • Prepare Your Data:
    • Copy the dataset and paste it into an Excel worksheet.

Excel Bar Chart Color by Category Using IF Function

    • In cell B16, define the lower and upper limits for each category (e.g., 0-64, 65-79, etc.).

Excel Bar Chart Color by Category Using IF Function

  • Create a Category Table:
    • Set up a table in the range B22:F32.
    • Distribute the scores into their respective categories (Below Average, Average, Good, and Excellent).

Excel Bar Chart Color by Category Using IF Function

  • Apply the IF Function:
    • In cell C23, enter the following formula:

=IF(AND($C$17<=$C5,$C5<=$D$17),$C5,"")
      • Here, C5 represents Robin’s score, while C17 and D17 define the min and max values for the Below Avg category.
      • The formula checks if Robin’s score falls within the specified range. If so, it displays the score; otherwise, it shows a blank cell.

Excel Bar Chart Color by Category Using IF Function

    • Drag the formula down to fill the remaining cells (e.g., C32 for Sandra’s score).

Excel Bar Chart Color by Category Using IF Function

    • Select cell D23 and enter the formula below.
=IF(AND($C$18<=$C5,$C5<=$D$18),$C5,"")
      • This formula is similar to the formula of our previous step. The difference is that here we used the cell reference of the Min and Max value of the Average category.

Excel Bar Chart Color by Category Using IF Function

    • Press the ENTER.
    • Drag the formula down to fill the remaining cells in columns E and F.

Excel Bar Chart Color by Category Using IF Function

  • Create the Bar Chart:
    • Select the entire table (B22:F32).
    • Go to the Insert tab and choose 2-D Clustered Bar Chart.
    • The chart will now be colored based on the categories.

Excel Bar Chart Color by Category Using IF Function

Excel Bar Chart Color by Category Using IF Function

  • Reverse the Y-Axis:
    • By default, Robin appears at the bottom of the Y-axis, which doesn’t match the data table.
    • Right-click on the Y-axis and select Format Axis.

Excel Bar Chart Color by Category Using IF Function

    • In the Format Axis task pane, click on Axis Options.
    • Check the box for Categories in reverse order.

Excel Bar Chart Color by Category Using IF Function

  • Now your chart will match the order of the data table.

Excel Bar Chart Color by Category Using IF Function

Read More: How to Change Bar Chart Color Based on Category in Excel


Method 2 – Manually Coloring Bars Using Format Options

In this method, we’ll customize the colors of individual bars based on their categories. Follow these steps carefully:

Steps:

  • Select Your Data Table:
    • Highlight the entire data table in the B4:C14 range.
  • Create the Bar Chart:
    • Go to the “Insert” tab.
    • Choose 2-D Clustered Bar under Column or Bar Chart.

Utilizing Format Option

    • This will create the bar chart, with all bars initially having the same color.

Utilizing Format Option

  • Color Individual Bars:
    • Select any bar in the chart.
    • Go to the Format tab.
  • Access Format Options:
    • In the Current Selection group, click on Format Selection.
    • The Format Data Point task pane will appear.

Utilizing Format Option

  • Choose a Fill Color:
    • Click on the Fill & Line icon.
    • From the Fill Color list, select your preferred color.

Utilizing Format Option

    • The selected bar will now be colored accordingly.

Utilizing Format Option

  • Repeat for Other Bars:
    • Repeat the process for each bar, assigning colors based on the categories defined in Method 1.

Utilizing Format Option

Note: While this method works well for smaller datasets, manually coloring bars becomes impractical for larger datasets (e.g., 100 rows).

Read More: Excel Bar Graph Color with Conditional Formatting


Download Practice Workbook

You can download the practice workbook from here:


Related Articles


<< Go Back to Excel Bar ChartExcel Charts | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Shahriar Abrar Rafid
Shahriar Abrar Rafid

Shahriar Abrar Rafid, BSc, Naval Architecture and Marine Engineering, Bangladesh University of Engineering and Technology, Bangladesh, has worked with the ExcelDemy project for more than 1 year. He has written over 100+ articles for ExcelDemy. He is a professional visual content developer adept at crafting scripts, meticulously editing Excel files, and delivering insightful video tutorials for YouTube channels. His work and learning interests vary from Microsoft Office Suites and Excel to Data Analysis, VBA, and Video recording and... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo