VBA & Macro Problems

Combine Excel Cells with Superscript Text Using VBA

Kushani NimanthikaKushani Nimanthika Oct 7, 2026 871 views

Question details

The user needs to merge text from two different cells and apply superscript formatting to a specific portion of the combined string.

Combine Excel Cells with Superscript Text Using VBA
Product
Excel
Device & OS
not provided
Scenario
Combining text fields where one part, such as a trademark symbol, mathematical power, or footnote reference, needs to be formatted as superscript in the final cell.
Observed behavior
Standard cell concatenation formulas (like CONCATENATE or the ampersand operator) strip all rich text formatting, leaving the result as plain text. The user must use VBA to programmatically reapply the superscript formatting after joining the text.
Before you start

Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that you have the Developer tab enabled on your ribbon to access the VBA Editor.

Solution 1Recommended

Use VBA Characters Property to Apply Superscript

This method uses a VBA macro to join the cell values together and then applies superscript formatting exclusively to the specific characters originating from the second cell.

Because regular Excel formulas cannot preserve text formatting when concatenating, VBA is required. The script works by merging the text into a destination cell and then calculating the length of the appended text to apply the '.Font.Superscript = True' property to just that segment.

1
Open the VBA Editor

Press 'Alt + F11' on your keyboard to open the Microsoft Visual Basic for Applications window.

2
Insert a New Module

In the top menu, click 'Insert' and select 'Module' to create a new blank script window.

3
Paste the Macro Code

Copy and paste the following code into the module window: Sub Test() With Range("C1") .Value = Range("A1") & Range("B1") .Characters(Len(.Value) - Len(Range("B1")) + 1).Font.Superscript = True End With End Sub

4
Run the Macro

Close the VBA editor and press 'Alt + F8'. Select 'Test' from the Macro dialog box and click 'Run'. The combined text will appear in cell C1 with the B1 segment formatted as superscript.

Use VBA Characters Property to Apply Superscript
Customizing Cell References: In the provided VBA code, Range("A1") is the base text, Range("B1") is the text to become superscript, and Range("C1") is the output cell. Update these references in the code to match your actual worksheet layout.
Advanced Spreadsheet Capabilities

Automate Formatting and Macros Easily in WPS Office

WPS Spreadsheet features a comprehensive, built-in Macro Editor that fully supports VBA scripting. You can seamlessly run scripts to concatenate cells, apply rich text formatting, and automate repetitive tasks just as you would in Microsoft Excel.

  1. 1. Download and Install: Get WPS Office from the official website and install it on your computer.
  2. 2. Open Your Spreadsheet: Launch WPS Spreadsheet and open your existing .xlsx or .xlsm file.
  3. 3. Access the Macro Editor: Navigate to the 'Tools' tab on the ribbon and click on 'Macro' to open the VBA editor.
  4. 4. Run Your Code: Paste your concatenation and superscript formatting VBA code and execute it instantly.
Fully compatible with Microsoft Excel formats, including Macro-Enabled Workbooks (.xlsm).Built-in VBA editor available in professional editions to run advanced macros effortlessly.Lightweight architecture ensures fast and smooth execution of complex data processing tasks.Clean, tabbed user interface that makes navigating between different spreadsheets simple.
microsoft office alternative - wps office

Frequently Asked Questions

Can I combine cells with superscript formatting using standard Excel formulas?

No, standard Excel formulas like CONCATENATE, TEXTJOIN, or using the ampersand (&) operator only extract the plain text values from cells. They do not carry over rich text formatting like bold, italic, or superscript. VBA is required to achieve this.

How do I apply subscript instead of superscript using VBA?

You can easily modify the provided VBA code to apply subscript. Change the property '.Font.Superscript = True' to '.Font.Subscript = True' before running the macro.

Why is my VBA code returning a 'Subscript out of range' error?

This error typically happens if the worksheet containing your target cells is not active, or if there is a typo in the Range references. Make sure you are on the correct active sheet or explicitly define the worksheet in the code, such as Sheets("Sheet1").Range("A1").