How to Separate Extracted Email Addresses with Semicolons in WPS Office VBA
Question details
The user needs to modify a VBA macro in WPS Office so that multiple extracted email addresses are joined with a semicolon and a space instead of a line break.

- Product
- WPS Office VBA Editor
- Device & OS
- not provided
- Scenario
- A VBA routine extracts email addresses from a document or worksheet and returns them as a single string; the user wants a semicolon-delimited list for use in email or data workflows.
- Observed behavior
- The current VBA code appends each extracted address with a line break separator, so the output string shows each address on a new line rather than as a semicolon-separated list.
Open the macro in the WPS Office VBA editor and locate the subroutine that builds the email address string. Confirm whether the current separator is Chr(10), vbLf, or another line-break character before editing.
Use a Conditional Separator Block to Join Email Addresses
Best when you want a clean semicolon-space-delimited list and need to avoid a leading separator before the first email address.
The safest approach is to use conditional logic so that the first extracted address is added without a separator and each following address is prefixed with a semicolon and a space.
In WPS Office, open the file containing the macro, press Alt+F11, or go to the Developer tab and click Macros to edit the relevant VBA routine.
Find the line that appends the extracted address, such as outStr = outStr & Chr(10) & getStr or a similar line-break separator.
Replace the separator line with: If outStr = "" Then outStr = getStr Else outStr = outStr & "; " & getStr End If.
Verify that the loop appends each valid character to getStr and only adds the separator after a complete email address is built.
Save the VBA module, run the macro, and confirm the returned string is formatted as address1; address2; address3.

Directly Replace the Line Break Separator
Use when you only need a minimal one-line change and your code already avoids adding a separator before the first address.
Edit the VBA Macro in WPS Office to Output Semicolon-Separated Email Addresses
WPS Office includes a familiar VBA editor where you can open the email extraction macro, replace the line-break separator with semicolon-space logic, and save the module. This lets you format extracted email addresses directly without switching to another Office suite.
- 1. Open the file and macro editor: Launch WPS Office, open the workbook or document that contains the email extraction macro, and press Alt+F11 or click Developer > Macros.
- 2. Locate the email extraction subroutine: In the VBA editor, find the subroutine that loops through text and builds the email address string.
- 3. Edit the separator logic: Replace the line-break separator with the conditional semicolon-space block so the first address is added without a separator.
- 4. Save and run: Save the module, close the VBA editor, and run the macro to verify that the resulting string is semicolon-separated.

Frequently Asked Questions
How do I open the VBA editor in WPS Office?
Open the file, press Alt+F11, or click the Developer tab and choose Macros. If the Developer tab is not visible, enable it through File > Options > Customize Ribbon.
Why does my macro add a semicolon before the first email address?
This happens when the separator line always prefixes "; " to each address, even when the output variable is empty. Use an If outStr = "" block to add the first address without a separator.
Can I separate extracted email addresses with a comma instead of a semicolon?
Yes. Replace "; " in the separator expression with ", " or another delimiter, and keep the conditional logic to avoid a leading delimiter.
Does WPS Office support VBA macros created in Microsoft Office?
WPS Office supports many VBA macros and can open macro-enabled Microsoft Office files. Open the file in WPS Office, review the code in the VBA editor, and test the separator change before relying on it.
What should I do if the extracted addresses still appear on separate lines?
Search the module for other line-break characters such as Chr(13), Chr(10), or vbCrLf, and replace those separators with "; " or the conditional separator block.




