If cell is bold excel

Written by Allen Wyatt (last updated February 1, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


Ken wonders if there is a worksheet function that will indicate whether the contents of a cell are bold. He can find other informational functions, such as ISBLANK, but cannot find one that will indicate if the cell is bold.

There is no ISBOLD function built into Excel. There is a very arcane way to do this without resorting to a macro, but it only works with some versions of Excel. Apparently, for example, this approach won’t work with Office 365, as it appears that Microsoft has finally removed support for it. This old Excel 4 function, called GET.CELL, will work with some older versions of Excel. Here is how you would use it in a formula:

=IF(GET.CELL(20,A1), "Bold", "Not Bold")

The GET.CELL function returns True if at least the first character in the cell is bold.

A better approach would be to create a User-Defined Function in VBA that could be called from your worksheet. Here’s a simple version of such a UDF:

Function CheckBold(cell As Range) As Boolean
    Application.Volatile
    CheckBold = cell.Font.Bold
End Function

In order to use it in your worksheet, you would do so in this manner:

=IF(CheckBold(A1), "Bold", "Not Bold")

The CheckBold function will only update when your worksheet is recalculated, not if you simply apply bold formatting to or remove it from cell A1.

This approach can work for most instances but understand that the Bold property can actually have three possible settings—True, False, and Null. The property is set to False if none of the characters in the cell are bold. It is set to True if they are all bold. Finally, it is set to Null if only some of the characters in the cell are bold. If you think you might run into this situation, then you’ll need to modify the CheckBold function:

Function CheckBold(cell As Range) As Integer
    Dim iBold As Integer

    Application.Volatile

    iBold = 0
    If IsNull(cell.Font.Bold) Then
        iBold = 2
    Else
        If cell.Font.Bold Then iBold = 1
    End If

    CheckBold = iBold
End Function

Note that the function now returns a value, 0 through 2. If it returns 0, there is no bold in the cell. If it returns 1, then the entire cell is bold. If it returns 2, then there is partial bold in the cell.

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I’ve prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training.
This tip (13733) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

Author Bio

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. Learn more about Allen…

MORE FROM ALLEN

Determining a State from an Area Code

Want to be able to take information that is in one cell and match it to data that is contained in a table within a …

Discover More

Editing a Comment Close to Its Cell

Have you ever chosen to edit a comment, only to find that the comment is quite a ways from the cell with which it is …

Discover More

Using Subtotals and Totals

You can insert subtotals and totals in your worksheets by using either a formula or specialized tools. This tip explains …

Discover More

I’m currently trying to create a calendar in Excel using VBA.
Now I need to check if a cell in column B is formatted bold. Due the fact that the line which is formatted bold can change its position, I need to check every single cell in column B, if its content is bold.

My current code:

Sub ScanBlock1()

Dim Zelle As Integer
Dim Cell As String
Dim found As Integer

Zelle = 7
Zell = "B" & Zelle
found = 0

'CopyCat.OpenCopyCat
Windows("Preset.xlsm").Activate

Do While found = 0
    Windows("Preset.xlsm").Activate
    Range(Zell).Select
    If Range(Zell).Font.Bold Then
        'Save start and end for copycat
        found = 1
    Else
        Zelle = Zelle + 2
    End If
Loop

End Sub

While trying this, I ran in to multiple problems.

First problem I have is, Excel just won’t automatically activate the requested window. I don’t know why. It worked all the time in other projects.

Second problem: I always get an overflow error in my IF Statement.
I think that it’s caused by Excel not activating my requested window.
EDIT: Because many people already wrote that it is an overflow error because NO BOLD CELL IS FOUND, the window I’d like to open/select is «full» of bold cells.

ChrisM's user avatar

ChrisM

1,5766 gold badges17 silver badges28 bronze badges

asked Jan 4, 2018 at 7:48

miit0o's user avatar

6

  1. Preset.xlsm must be open if you want to Activate it.
  2. Capture the error within your app.
  3. The second Activation (within the loop) in not necessary
  4. You increase the value of zellE (endlessly) but you do not update Zell

Try this:

Zelle = 7
zMAX=1000

found = 0
Windows("Preset.xlsm").Activate
if Err.Number <> 0 then goto errorlabel   ' process error

Do While found = 0 or Zelle < zMAX
    Zell = "B" & Zelle
    If Range(Zell).Font.Bold Then
        'Save start and end for copycat
        found = 1
    Else
        Zelle = Zelle + 2
    End If
Loop

If Zelle >= zMAX then
   Msgbox "Problem!"
Endif

I personnaly prefer direct cell references instead of bothering with strings, so here you are an alternativ solution:

zMAX=1000
Windows("Preset.xlsm").Activate
if Err.Number <> 0 then goto errorlabel   ' process error

for Zelle = 7 to zMAX Step 2
    If Cells(Zelle, 2).Font.Bold Then Exit For ' "2" for column "B"
Next
If Zelle >= zMAX then
   Msgbox "Problem!"
Else
   ' Bold found, Save start and end for copycat
Endif

answered Jan 4, 2018 at 8:22

AcsErno's user avatar

AcsErnoAcsErno

1,5871 gold badge7 silver badges10 bronze badges

2

You have defined Zelle as integer, it may be maximally 32767 while Excel has about one million rows. The quick solution would be changing declaration:

Dim Zelle As Integer

But it may take a long time to run this macro. You should rather restrict this to UsedRange and use object loop. Like:

Dim cl as Range

For each cl in Workbooks("Preset.xlsm").Worksheets(1).UsedRange
  If Range(Zell).Font.Bold Then
     'Do something
  End If
Next cl

This will work for the first sheet of Preset.xlsm but you can indicate other sheet of course.

@comment below: Why iterating over all cells in UsedRange? OP needs only column B.

well, it would be faster this way:

For each cl in Workbooks("Preset.xlsm").Worksheets(1).UsedRange.Columns(2)

answered Jan 4, 2018 at 8:06

MarcinSzaleniec's user avatar

MarcinSzaleniecMarcinSzaleniec

2,2361 gold badge7 silver badges22 bronze badges

2


June 29, 2015/



Chris Newman

Excel Functions IsBold IsColor IsItalic IsUnderlined

Wishful Thinking?

 Have you ever had a time where you wished you could write an IF formula in Excel based on whether or not a cell was filled with the color green or not? Unfortunately, Excel doesn’t have a built-in «IsGreen» function you can call to perform such logic. However, with the power of VBA you can write your own functions and actually call them from the Formula Bar!  This can be extremely powerful and extends Excel’s logical prowess to a near limitless level! Let’s take a look at how we can add our own functions into our spreadsheets.

Where Do I Write The Function Logic?

I recommend storing your custom functions inside a VBA module. Here are the steps to create a brand new module within your spreadsheet.

  1. Inside your spreadsheet use the keyboard shortcut Alt + F11 to open up the Visual Basic Editor window

  2. On the left-hand side of the window, you should see a Project pane that will display every Excel workbook/add-in you currently have open

  3. Find the Project Name that matches the Excel file you want to store the functions in and right-click on the Project Name

  4. Inside the menu that pops up, go to Insert -> Module

  5. A blank white canvas should appear on your screen and this is where you will want to write or paste in your custom function code

Examples of Functions You Can Add

This is where you can let your imagination run wild (especially if you have a good grasp on how to write VBA). But in case you are new to VBA (you can learn how to get started learning to write VBA here),  I am going to provide you with a few common functions that might be useful when trying to logically analyze a cell’s formatting.

Function To Determine If Cell Text Is Bold

Function ISBOLD(cell As Range) As Boolean
‘PURPOSE: Determine if cell has bold text or not
‘SOURCE: www.TheSpreadsheetGuru.com

‘Ensure function will recalculate after spreadsheet changes
  Application.Volatile True

‘Test Cell Value
  On Error GoTo PartiallyBold
    ISBOLD = cell.Font.Bold
  On Error GoTo 0

Exit Function

‘Handle if only part of the cell value is bolded
PartiallyBold:
  If Err.Number = 94 Then ISBOLD = True

End Function

Function To Determine If Cell Text Is Italicized

Function ISITALIC(cell As Range) As Boolean
‘PURPOSE: Determine if cell has italicized text or not
‘SOURCE: www.TheSpreadsheetGuru.com

‘Ensure function will recalculate after spreadsheet changes
  Application.Volatile True

‘Test Cell Value
  On Error GoTo PartiallyItalic
    ISITALIC = cell.Font.Italic
  On Error GoTo 0

Exit Function

‘Handle if only part of the cell value is italicized
PartiallyItalic:
  If Err.Number = 94 Then ISITALIC = True

End Function

Function To Determine If Cell Text Is Underlined

Function ISUNDERLINED(cell As Range) As Boolean
‘PURPOSE: Determine if cell has underlined text or not
‘SOURCE: www.TheSpreadsheetGuru.com

‘Ensure function will recalculate after spreadsheet changes
  Application.Volatile True

‘Test Cell Value
  If cell.Font.Underline = xlNone Then
    ISUNDERLINED = False
  Else
    ISUNDERLINED = True
  End If

End Function

Function To Determine If Cell Text Is A Specific Color

Function ISFONTCOLOR(cell As Range, TargetColor As Range) As Boolean
‘PURPOSE: Test if cell font color matches a specified cell fill color
‘NOTE: Color changes will not trigger your spreadsheet to re-calculate
‘SOURCE: www.TheSpreadsheetGuru.com

‘Ensure function will recalculate after spreadsheet changes
  Application.Volatile True

‘Test Cell Font Color
  If cell.Font.Color = TargetColor.Interior.Color Then
    ISFONTCOLOR = True
  Else
    ISFONTCOLOR = False
  End If

End Function

Function To Determine If Cell Fill Is A Specific Color

Function ISFILLCOLOR(cell As Range, TargetColor As Range) As Boolean
‘PURPOSE: Test if cell fill color matches a specified cell fill color
‘NOTE: Color changes will not trigger your spreadsheet to re-calculate
‘SOURCE: www.TheSpreadsheetGuru.com

‘Ensure function will recalculate after spreadsheet changes
  Application.Volatile True

‘Test Cell Fill Color
  If cell.Interior.Color = TargetColor.Interior.Color Then
    ISFILLCOLOR = True
  Else
    ISFILLCOLOR = False
  End If

End Function

Calling A Custom Function

Once you have written your function in the VBA module, you can then start to use it! Simply begin typing the function inside the formula bar and you will see your custom function appear as a viable selection. Note that you will not get any ScreenTips with your custom functions (come on Microsoft!), so you will need to memorize how to properly use your custom function.

Use A Custom Function IsBold In Formula Bar

Formula Recalculation

You will need to be careful with these formulas since changing the format of a cell does not trigger a spreadsheet recalculation. Always make sure you hit the F9 key before you begin your analysis while using a custom function that takes into account formatting in your spreadsheets.

Download An Example File With These Functions

To help you further, I have created an example workbook with all the custom functions described in this article put to use so you can see them in action.

If you would like to get a copy of the Excel file I used throughout this article, feel free to directly download the spreadsheet by clicking the download button below.

About The Author

Hey there! I’m Chris and I run TheSpreadsheetGuru website in my spare time. By day, I’m actually a finance professional who relies on Microsoft Excel quite heavily in the corporate world. I love taking the things I learn in the “real world” and sharing them with everyone here on this site so that you too can become a spreadsheet guru at your company.

Through my years in the corporate world, I’ve been able to pick up on opportunities to make working with Excel better and have built a variety of Excel add-ins, from inserting tickmark symbols to automating copy/pasting from Excel to PowerPoint. If you’d like to keep up to date with the latest Excel news and directly get emailed the most meaningful Excel tips I’ve learned over the years, you can sign up for my free newsletters. I hope I was able to provide you with some value today and I hope to see you back here soon!

— Chris
Founder, TheSpreadsheetGuru.com

  • #3

I do not believe it could be possible to detect BOLD with a formula. Because it is font formatting. I don’t think ASCII is used to create bold characters and I am not sure what else would come close to detecting it. You could write a macro that detects BOLD print and highlights the row. I would recommend that it be a button you press on your spreadsheet, but you could make it automatic. The latter can slow down your spreadsheet greatly, but not knowing your spreadsheet, maybe it wouldn’t be an issue.

I get this query all the time. People have huge data sets and someone in their team has highlighted some records by formatting it in bold font.

Now, you are the one who gets this data, and you have to filter all these records that have a bold formatting.

For example, suppose you have the data set as shown below, and you want to filter all the cells that have been formatted in bold font.

Formatting in Excel - Filter Bold

Let’s face it.

There is no straightforward way of doing it.

You cannot simply use an Excel filter to get all the bold cells. But that doesn’t mean you have to waste hours and do it manually.

In this tutorial, I will show you three ways to filter cells with bold font formatting in Excel:

Filter Cells with Bold Font Formatting in Excel - Image

Method 1 – Filter Bold Cells Using Find and Replace

Find and Replace can be used to find specific text in the worksheet, as well as a specific format (such as cell color, font color, bold font, font color).

The idea is to find the bold font formatting in the worksheet and convert it into something that can be easily filtered (Hint: Cell color can be used as a filter).

Here are the steps filter cells with bold text format:

  1. Select the entire data set.
  2. Go to the Home tab.
  3. In the Editing group, click on the Find and Select drop down.
  4. Click on Replace. (Keyboard shortcut: Control + H)filter by bold font format in Excel - Click on Replace
  5. In the Find and Replace dialog box, click on the Options button.how to filter bold text in Excel - Click on Options
  6. In the Find what section, go to the Format drop-down and select ‘Choose Format From Cell’.Choose bold font format from cell directly
  7. Select any cell which has the text in bold font format.filter by bold font format in Excel - Preview
  8. In the ‘Replace with:’ section, go to Format drop-down and click on ‘Choose Format From Cell’ option.Select the format with which you want to replace bold font
  9. In the Replace Format dialog box, select the Fill Tab and select any color and click OK (make sure it’s a color that is not there already in your worksheet cells).
  10. Click on Replace All. This will color all the cells that have the text with bold font formatting. Formatting in Excel - bold cells colored

In the above steps, we have converted the bold text format into a format that is recognized as a filter criterion by Excel.

Now to filter these cells, here are the steps:

  1. Select the entire data set.
  2. Go to the Data tab.
  3. Click on the Filter icon (Key Board Shortcut: Control + Shift + L)Filter Icon in the ribbon
  4. For the column that you want to filter, click on the filter icon (the downward pointing arrow in the cell).
  5. In the drop-down, go to the ‘Filter by Color’ option and select the color you applied to cells with text in bold font format.Filter cell with text with bold font formatting - filter by color

This will automatically filter all those cells that have bold font formatting in it.

Try it yourself.. Download the file

Method 2 – Using Get.Cell Formula

It time for a hidden gem in Excel. It’s an Excel 4 macro function – GET.CELL().

This is an old function which does not work in the worksheet as regular functions, but it still works in named ranges.

GET.CELL function gives you the information about the cell.

For example, it can tell you:

  • If the cell has bold formatting or not
  • If the cell has a formula or not
  • If the cell is locked or not, and so on.

Here is the syntax of the GET.CELL formula

=GET.CELL(type_num, reference)
  • Type_num is the argument to specify the information that you want to get for the referenced cell (for example, if you enter 20 as the type_num, it would return TRUE if the cell has a bold font format, and FALSE if not).
  • Reference is the cell reference that you want to analyze.

Now let me show you how to filter cells with text in a bold font format using this formula:

  1. Go to Formulas tab.
  2. Click on the Define Name option.Select Define Name in Formula Tab
  3. In the New Name dialog box, use the following details:
    • Name: FilterBoldCell
    • Scope: Workbook
    • Refers to: =GET.CELL(20,$A2)Create a new Named Range to use getcell function
  4. Click OK.
  5. Go to cell B2 (or any cell in the same row as that of the first cell of the dataset) and type =FilterBoldCell
  6. Copy this formula for all the cell in the column. It will return a TRUE if the cell has bold formatting and FALSE if it does not.
  7. Now select the entire data set, go to the Data tab and click on the Filter icon.
  8. In the column where you have TRUE/FALSE, select the filter drop-down and select TRUE.Select TRUE to filter cells that have text with bold font format in cells

That’s it!

All the cells with text in bold font format have now been filtered.

Note: Since this is a macro function, you need to save this file with a .xlsm or .xls extension.

I could not find any help article on GET.CELL() by Microsoft. Here is something I found on Mr. Excel Message Board.

Try it yourself.. Download the file

Method 3 – Filter Bold Cells using VBA

Here is another way of filtering cells with text in bold font format by using VBA.

Here are the steps:

  1. Right-click on the worksheet tab and select View Code (or use the keyboard shortcut ALT + F11). This opens the VB Editor backend.Right click on the sheet tab and click on view code
  2. In the VB Editor window, there would be the Project Explorer pane. If it is not there, go to View and select Project Explorer.Project Explorer in the Backend
  3. In the Project Explorer pane, right click on the workbook (VBAProject) on which you are working, go to Insert and click on Module. This inserts a module where we will put the VBA code.Insert a Module for function to filter sort cells with bold font format
  4. Double click on the module icon (to make sure your code into the module), and paste the following code in the pane on the right:
    Function BoldFont(CellRef As Range)
    BoldFont = CellRef.Font.Bold
    End Function
  5. Go to the worksheet and use the below formula: =BoldFont(B2)
  6. This formula returns TRUE wherever there is bold formatting applied to the cell and FALSE otherwise. Now you can simply filter all the TRUE values (as shown in Method 2)using custom function to filter cells with bold font formatting

Again! This workbook now has a macro, so save it with .xlsm or .xls extension

Try it yourself.. Download the file

I hope this will give you enough time for that much-needed coffee break 🙂

Do you know any other way to do this? I would love to learn from you. Leave your thoughts in the comment section and be awesome.

You May Also Like the Following Excel Tutorials:

  • An Introduction to Excel Data Filter Options.
  • Filter By Color in Excel
  • Create Dynamic Excel Filter – Extract Data as you type.
  • Creating a Drop Down Filter to Extract Data Based on Selection.
  • Filter the Smart Way – Use Advanced Filter in Excel
  • Count Cells Based on a Background Color.
  • Highlight Blank Cells in Excel.
  • How to Create a Heat Map in Excel.
  • Excel VBA Autofilter.

Понравилась статья? Поделить с друзьями:
  • Idioms word of the day
  • If cell content excel
  • Idioms with word world
  • If cell contains word
  • If cell contains any text in excel