Often you may want to filter cells in Excel based on whether or not the cells have bold font.
For example, suppose we have the following dataset and we’d like to filter the cells to only show the ones that have a bold font:
The easiest way to do this is by writing some code in VBA in Excel.
The following step-by-step example shows exactly how to do so.
Step 1: Enter the Data
First, enter the data values into Excel:
Step 2: Show the Developer Tab in Excel
Next, we need to make sure the Developer tab is visible on the top ribbon in Excel.
To do so, click the File tab, then click Options, then click Customize Ribbon.
Under the section called Main Tabs, check the box next to Developer, then click OK:
Step 3: Create a Macro Using VBA
Next, click the Developer tab along the top ribbon and then click the Visual Basic icon:
Next, click the Insert tab and then click Module from the dropdown menu:
Next, paste the following code into the module code editor:
Function FindBold(r As Range)
FindBold = r.Font.Bold
The following screenshot shows how to do so:
Once you’ve entered the code, feel free to close out of the VB Editor. The code will automatically be saved.
Step 4: Use the Macro to Check if Cells have Bold Font
Next, type the following formula into cell B2 to check if cell A2 has bold font or not:
Click and drag this formula down to each remaining cell in column B:
Column B now returns TRUE or FALSE to indicate if the each corresponding cell in column A has bold font or not.
Step 5: Filter by Bold Font
Now that we have a column with TRUE and FALSE values, we can simply filter the rows based on the values in this new column.
To do so, highlight the cell range A1:B11, then click the Data tab along the top ribbon, then click the Filter icon within the Sort & Filter group.
Then click the dropdown arrow next to the header Bold Font? and uncheck the box next to FALSE:
Once you click OK, the rows will be filtered to only show the ones where the team name has bold font:
Note: Feel free to uncheck the box next to TRUE to instead filter for cells that do not have bold font.
The following tutorials explain how to perform other common tasks in Excel: