VBA & Macro Problems

How to Automate Combining Overflow Names in WPS Excel with a VBA Macro

Steven ParkerSteven Parker Nov 13, 2026 868 views

Question details

The user needs a script-based way to combine name fragments that either overflow visually or are stored in adjacent columns, confirming the data layout before running automation.

How to Automate Combining Overflow Names in WPS Excel with a VBA Macro
Product
WPS Office Excel (WPS Spreadsheets)
Device & OS
not provided
Scenario
A worksheet contains names that spill into neighboring cells or are split across columns C and D, and the user wants to automate combining the fragments.
Observed behavior
Overflowing names appear split, and continuation text in column D must be appended to column C before the source cell is cleared.
Before you start

Before writing the macro, confirm whether the overflow is cell overflow from an empty adjacent cell or whether name fragments are actually stored in columns C and D. Run the test on a copy of the workbook so clearing the source cells can be reverted if the layout differs.

Solution 1Recommended

Run a VBA Macro to Append Column D Overflow Name Fragments to Column C

Use this method when your layout stores the base name in column C and the continuation in column D, and you want a repeatable automated cleanup.

WPS Office Excel supports VBA macros, so you can loop through the used range, combine the two name fragments, and clear the source cell in one pass. The macro below assumes row 1 is a header and the data starts at row 2.

1
Open the VBA editor

In WPS Office Excel, click the Developer tab > Visual Basic, or press Alt+F11. If the Developer tab is not visible, enable it from File > Options > Customize Ribbon.

2
Insert a module

In the VBA editor, click Insert > Module to create a new module where the macro code will be stored.

3
Paste the macro code

Paste the following code and adjust the column letters if your fragments are not in columns C and D: Sub CombineOverflowNames() Dim ws As Worksheet Set ws = ActiveSheet Dim lastRow As Long lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row Dim i As Long For i = 2 To lastRow If Trim(ws.Cells(i, "D").Value) <> "" Then ws.Cells(i, "C").Value = Trim(ws.Cells(i, "C").Value) & " " & Trim(ws.Cells(i, "D").Value) ws.Cells(i, "D").ClearContents End If Next i End Sub

4
Run the macro

Click inside the Sub CombineOverflowNames procedure and press F5, or select Run > Run Sub/UserForm. WPS Excel will process each row from row 2 to the last used row in column C.

5
Verify the result

Check that column C contains the complete name and column D is empty for the processed rows. If the result is incorrect, close the test copy without saving and adjust the column references.

Run a VBA Macro to Append Column D Overflow Name Fragments to Column C
Automation completed: The macro appends column D text to column C only when column D is not blank, then clears column D for those rows.

Automate Overflow Name Cleanup with WPS Excel VBA

WPS Office Excel includes a built-in VBA editor that can loop through columns C and D, combine overflow name fragments, and clear the continuation cells. Save the result as a macro-enabled Excel file so the cleanup can be run again on future sheets.

  1. 1. Open the workbook in WPS Office Excel: Launch WPS Office Excel, open your workbook, and confirm that the name fragments are located in adjacent columns such as C and D.
  2. 2. Open the VBA editor: Press Alt+F11 or go to Developer > Visual Basic to open the built-in VBA editor.
  3. 3. Insert and run the cleanup macro: Insert a module, paste the macro that tests column D, appends non-blank text to column C, and clears column D. Run it with F5.
  4. 4. Save as a macro-enabled workbook: Click File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm) to preserve the automation for future use.
Automates repeated overflow-name combining across large worksheetsFully compatible with .xlsm and .xlsx files from Microsoft ExcelFree and lightweight Office suite with a familiar VBA editorLets you test and run macros without changing your existing workbook layout
microsoft office alternative - wps office

Frequently Asked Questions

How do I know whether my overflowing names are split across columns or just visually spilling over?

Select the adjacent cell. If the formula bar shows a value, the text is stored in that cell; if it is empty, the name is only overflowing from the left cell. You can also check columns C and D with the arrow keys.

Does WPS Office Excel support VBA macros like Microsoft Excel?

Yes. WPS Office Excel includes a VBA editor that can be opened with Alt+F11 or through the Developer tab, and it can run macro-enabled .xlsm workbooks.

Can I combine overflow names without writing a macro?

Yes. Use a helper column with =TRIM(C2&" "&D2), fill it down, then paste the results into column C as values and delete the helper column.

What should I check before running a macro that clears cells in column D?

Confirm the data layout on a copy of the workbook, note any blank rows or names with spaces, and verify that column D only contains continuation text you intend to clear.