In Excel VBA, make a cell or range bold by setting its Font.Bold property to True, such as Range("A1").Font.Bold = True. To bold only some characters inside a cell, use the cell’s Characters method and specify the starting position and number of characters.
How the Font.Bold property works
Excel exposes a cell’s font formatting through its Font object. The Bold property controls whether the font is bold; assigning True applies bold formatting, while assigning False removes it. The setting is a formatting change, not a change to the cell’s value or formula.
For example, to format A1 on the active worksheet, use Range("A1").Font.Bold = True. This is concise, but it depends on which worksheet is active when the macro runs. For code that may run from another sheet or workbook, explicitly identify the workbook and worksheet instead.
The property can also return a value. If every cell in a range has the same bold setting, the result is True or False. If a range contains a mixture of bold and non-bold cells, Excel may return Null to indicate that there is no single value for the whole range. That matters when writing code that checks formatting before changing it.
Bold an entire cell or range
Set Font.Bold on a Range object to format one cell, a block, a row, a column, or multiple cells. The following macro bolds a heading in A1 and the cells B2:B10 on a worksheet named Report in the workbook containing the macro.
Before running any macro, save a copy of the workbook. VBA changes cannot be reversed with Ctrl+Z, so a backup is the simplest way to preserve the original formatting if the macro targets the wrong cells.
Sub BoldReportCells()
Dim ws As Worksheet
' Use the worksheet in the workbook containing this macro.
Set ws = ThisWorkbook.Worksheets("Report")
ws.Range("A1").Font.Bold = True
ws.Range("B2:B10").Font.Bold = True
End Sub
Change the sheet name and addresses to match the workbook. A range can also be written as ws.Range("A1:C5"), while full-row and full-column references can be given as ws.Rows(1) and ws.Columns("B"). Use a limited range when possible: formatting an entire worksheet column may affect more cells than the task requires.
To remove bold formatting, use the same target and assign False, as in ws.Range("B2:B10").Font.Bold = False. This is more predictable than toggling because it always leaves the cells non-bold, even if their original state varied.
Bold only part of a cell’s text
When a cell contains a label, sentence, or other text and only a portion should be emphasized, use the Characters method. Its position is one-based: the first character is position 1. The Length argument counts how many characters to format. For example, with the text “Total due: $125” in A1, the word “Total” begins at position 1 and contains five characters.
Save a copy before running this macro as well; character-level formatting is still a VBA formatting change and cannot be undone with Ctrl+Z.
Sub BoldFirstWord()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Report")
' A1 must contain text beginning with the five-letter word Total.
ws.Range("A1").Characters(1, 5).Font.Bold = True
End Sub
Characters formatting applies to text within a single cell. It is not a way to format only part of a multi-cell range. If a cell is blank, contains a number rather than text, or has fewer characters than the requested start and length, the intended result may not be meaningful. For reliable results, check that the target cell contains the expected text before applying character formatting.
To bold a phrase that may appear at different positions, first locate its position in the cell’s text, then pass that position and the phrase length to Characters. Make sure the search succeeds before using the position; a failed search commonly returns zero, but Characters positions start at 1. For cells that can contain formulas, also decide whether the macro should format the displayed result or only handle text values you explicitly provide.
Set bold deliberately instead of toggling
A common shortcut is to invert the current state: Range("A1").Font.Bold = Not Range("A1").Font.Bold. This works for a single cell whose Bold value is True or False, but it is not a good general approach for a mixed range. If Font.Bold returns Null for that range, Not cannot produce a dependable Boolean result.
Prefer setting the desired state explicitly. Assign True when the aim is to make a heading bold, and False when the aim is to clear bold. If a user specifically needs to switch a single cell back and forth, handle the current value first. For a range, choose a clear rule—such as “make all cells bold” or “make all cells non-bold”—rather than trying to invert an ambiguous mixed state.
Also avoid relying on the active selection in reusable code. Selection.Font.Bold = True can work when the intended cells are selected, but a user may have selected something else. A named worksheet and explicit range make the macro’s target easier to review and reduce accidental formatting changes.
Apply bold to multiple cells efficiently
For a known block, apply formatting to the whole range in one statement instead of looping through every cell. This is simpler and usually more efficient than changing cells individually. Use a loop when the target depends on a condition, such as bolding only rows whose status column says “Overdue.”
In the following example, the worksheet named Report has statuses in column C and the cells to bold are in columns A through C. The loop checks rows 2 through 100, then applies bold to the row’s three cells only when the status matches. Adjust the last row and the status text for the actual data.
Save a copy of the workbook before running this macro, because its formatting changes cannot be undone with Ctrl+Z.
Sub BoldOverdueRows()
Dim ws As Worksheet
Dim rowNumber As Long
Set ws = ThisWorkbook.Worksheets("Report")
For rowNumber = 2 To 100
If ws.Cells(rowNumber, 3).Value = "Overdue" Then
ws.Range(ws.Cells(rowNumber, 1), _
ws.Cells(rowNumber, 3)).Font.Bold = True
End If
Next rowNumber
End Sub
For a large or changing dataset, avoid assuming that row 100 is always the end. Determine the last used row in the relevant column, and account for blank rows or headers in your data. A fixed, documented range can still be appropriate for a small, stable report; the important point is that the macro’s boundaries are intentional.
Manual formatting, conditional formatting, and VBA
VBA is useful when bold formatting must be repeated, triggered by a process, or applied according to custom logic. For a one-time change, selecting cells and using the Bold button on the Home tab is usually quicker. The Windows shortcut is Ctrl+B; on Mac, use Command+B. Excel for the web supports ordinary manual formatting, but it does not run VBA macros, so open the workbook in desktop Excel to run VBA.
Conditional formatting is often a better fit when bold should change automatically as values change. For example, a rule can emphasize overdue dates without running a macro each time the data is updated. Use Home > Conditional Formatting to create or manage rules. A VBA macro that sets Font.Bold is a direct format change; it does not create a conditional rule that reevaluates when the cell value changes.
Conditional formatting can affect how formatting appears on screen. If a cell looks bold even after VBA sets its Font.Bold property to False, inspect the applicable conditional-formatting rules as well as the cell’s ordinary formatting. Conversely, when a condition stops applying, the cell’s normal formatting becomes visible again.
Common problems and how to fix them
- The macro changes the wrong sheet. An unqualified Range refers to the active sheet. Use a Worksheet variable and write
ws.Range("A1")so the intended sheet is explicit. - The sheet name is wrong. The worksheet name in the code must match the tab name, including spaces. A missing or misspelled sheet name causes a runtime error.
- The macro does not run. Excel for the web cannot execute VBA. In desktop Excel, check that the workbook is saved in a macro-enabled format such as .xlsm and that the file’s macro security settings allow trusted code to run. Do not enable macros in a file from an untrusted source.
- Only part of a cell should be bold, but the whole cell changes. Use
Range("A1").Characters(start, length).Font.Boldfor rich-text formatting within a text cell, rather than setting Font.Bold on the entire Range. - A mixed range behaves unexpectedly. Font.Bold can return Null when selected cells do not share a single bold state. Set the range explicitly to True or False instead of applying Not to the property.
- The visible result does not match the code. Check conditional formatting, verify that the code targeted the expected workbook and sheet, and confirm that the cell’s font supports a bold style. A font family may display bold differently, but the VBA property still requests bold formatting.
Running VBA safely in Excel
In desktop Excel for Windows, open the Visual Basic Editor with Alt+F11, insert a standard module using Insert > Module, and paste a Sub procedure into the module. Run a procedure from the editor with F5 when the cursor is inside it, or return to Excel and use Developer > Macros. If the Developer tab is not visible, enable it through File > Options > Customize Ribbon.
On Mac, Excel also supports VBA, though some editor details and keyboard shortcuts differ by version and keyboard. The core formatting statements shown here use Excel’s VBA object model. Excel for the web has no VBA editor or macro execution; a workbook containing VBA must be opened in a desktop Excel app to run its macros.
Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if it needs to retain VBA code. Before running a macro, review the target range and save a separate copy. Macros can change many cells quickly, and Excel’s normal Undo history does not restore VBA changes. Keep macros narrowly scoped and run code only when you understand its source and purpose.
Frequently Asked Questions
What is the VBA code to make a cell bold?
Use Range("A1").Font.Bold = True to bold A1 on the active worksheet. For more reliable targeting, qualify it with a worksheet variable, such as ws.Range("A1").Font.Bold = True.
How do I make text unbold in VBA?
Set the target’s Bold property to False: Range("A1").Font.Bold = False. This removes bold formatting from the cell or range addressed by the code.
Can VBA bold just one word in a cell?
Yes. Use the cell’s Characters method with the word’s starting character and its length, then set that character range’s Font.Bold property to True. Character positions start at 1, and this approach is for text within one cell.
Why does Font.Bold return Null?
A range with mixed formatting has no single bold value, so Excel can return Null. Assign True or False to set a consistent state, or examine cells individually if the code needs to preserve their different formatting.
Can Excel for the web run an Excel VBA macro?
No. Excel for the web can display and edit many workbook features, but VBA macros must be run in desktop Excel. Open the workbook in the desktop app to use its VBA editor and macro commands.
Related
- Excel Data Model vs Power Query: How They Work Together
- Excel Data Analysis: Where to Click and How to Practice
- Excel Data Model: How to Group Dates in PivotTables
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA Not Working? Diagnose Common Macro ProblemsIf Excel VBA is not working, first check that you are using the desktop version of Excel, the…
- Excel VBA AutoFilter: Examples, Criteria, and FixesExcel VBA AutoFilter filters a worksheet range or Excel table by applying criteria to one or more columns.…
- Add Comments in Excel VBA: Notes and Threaded CommentsTo add a cell note with Excel VBA, select the cell and run ActiveCell.AddComment "Check this value." in…
- Excel Macro Error? Common Causes and FixesAn Excel macro error usually means VBA is blocked, the code cannot find an expected workbook, worksheet, or…
- Excel UserForm Combo Box: Add, Populate, and Use ItAn Excel UserForm combo box is a VBA control that lets someone choose an item from a drop-down…
- VBA Resize Pictures to Fit in Excel Cells AutomaticallyTo resize pictures to fit inside Excel cells with VBA, run a macro that finds each picture, scales…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.