VBA & Macro Problems

How to Make Text Bold After Specific Characters in Excel VBA

John WilsonJohn Wilson Nov 11, 2026 868 views

Question details

The user needs a method to automate the formatting of text within a range of cells, specifically applying a bold font style to all characters that appear immediately after a specific substring (e.g., 'MM').

How to Make Text Bold After Specific Characters in Excel VBA
Product
Excel
Device & OS
not provided
Scenario
Formatting partial text strings across multiple rows in an Excel spreadsheet without manually editing each cell.
Observed behavior
Text inside the cells has uniform formatting. A VBA programmatic solution is required to isolate and bold only the portion of the string following a designated marker.
Before you start

Ensure you are using a desktop version of Excel, as VBA macros are not supported in Excel for the Web. You should also verify that the Developer tab is enabled in your ribbon to access the Visual Basic Editor.

Solution 1Recommended

Use a VBA Macro to Format Partial Text

This method utilizes Excel's Visual Basic for Applications (VBA) to search for the specific characters ('MM') and apply bold formatting to the remainder of the cell's content.

By utilizing the InStr function in VBA, Excel can identify the exact starting position of your target string. We can then use the Characters object to apply the Bold property to everything following that position.

This macro is specifically written to check values starting from cell A2 downwards. You can adjust the Range values if your data is located in a different column.

1
Open the Visual Basic Editor

Press Alt + F11 on your keyboard to launch the Visual Basic Editor in your desktop version of Excel.

2
Insert a New Module

From the top menu, click 'Insert' and select 'Module' to open a blank coding window.

3
Enter the VBA Code

Copy and paste the following code into the module window: Sub BoldAfterMM() Dim c As Range Dim p As Long Application.ScreenUpdating = False For Each c In Range(Cell1:=Range("A2"), Cell2:=Range("A2").End(xlDown)) p = InStr(c.Value, "MM") If p > 0 Then c.Characters(Start:=p + 2, Length:=1000).Font.Bold = True End If Next c Application.ScreenUpdating = True End Sub

4
Run the Macro

Place your text cursor anywhere inside the code and press F5 on your keyboard to execute the macro and format your text.

5
Save as a Macro-Enabled Workbook

To keep the macro for future use, click 'File' > 'Save As' and choose 'Excel Macro-Enabled Workbook (*.xlsm)' from the file format dropdown menu.

Use a VBA Macro to Format Partial Text
Customizing the Target Text: If you want to search for a word longer or shorter than 'MM', you must change both the search string in the InStr line and adjust 'Start:=p + 2' to match the character count of your new target word.
Automate Formatting with WPS Spreadsheet

Run VBA Macros Seamlessly in WPS Office

WPS Office fully supports VBA macros, allowing you to run the exact same script to apply bold formatting to specific characters. It provides an efficient and highly compatible spreadsheet environment for all your automation needs.

  1. 1. Open Your Spreadsheet in WPS: Launch WPS Spreadsheet and open the document containing the data you want to format.
  2. 2. Access the VBA Editor: Navigate to the 'Developer' tab on the top ribbon and click 'VB Editor', or simply press Alt + F11.
  3. 3. Insert and Run the Code: Click 'Insert' > 'Module', paste the VBA code provided in the solution above, and press F5 to execute the formatting script.
Full compatibility with Microsoft Excel macro-enabled formats (.xlsm).Built-in VBA editor to write, run, and debug formatting scripts easily.Lightweight software that runs quickly without consuming heavy system resources.Familiar interface that eliminates the learning curve when migrating from Microsoft Excel.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't the macro working in Excel for the Web?

VBA macros rely on the desktop architecture of Excel. Excel for the Web does not support the execution of VBA scripts. You must open your file in the desktop application to run the macro.

How do I apply this macro to a different column?

In the VBA code, locate the line `Range(Cell1:=Range("A2"), Cell2:=Range("A2").End(xlDown))`. Change both instances of 'A2' to the starting cell of your desired column, such as 'B2' or 'C2'.

Will this macro override my existing cell formatting?

The macro explicitly targets the Characters object's Font.Bold property for the text following the target string. It will leave the font color, size, and other attributes intact, but the specific targeted substring will become bold.

Do I have to change the file format after adding a macro?

Yes. Standard Excel workbooks (.xlsx) cannot store VBA code. You must save the document as an Excel Macro-Enabled Workbook (.xlsm) to ensure your script is saved for future sessions.