How to Automate Combining Overflow Names in WPS Excel with a VBA Macro
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.

- 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 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.
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.
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.
In the VBA editor, click Insert > Module to create a new module where the macro code will be stored.
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
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.
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.

Use a Helper Formula and Paste Values to Combine Overflow Names Without a Macro
Use this method when you only need a one-time cleanup or cannot enable macros in the workbook.
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. 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. Open the VBA editor: Press Alt+F11 or go to Developer > Visual Basic to open the built-in VBA editor.
- 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. Save as a macro-enabled workbook: Click File > Save As and choose Excel Macro-Enabled Workbook (*.xlsm) to preserve the automation for future use.

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.




