VBA & Macro Problems

How to Separate Extracted Email Addresses with Semicolons in WPS Office VBA

Kushani NimanthikaKushani Nimanthika Nov 13, 2026 870 views

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.

How to Separate Extracted Email Addresses with Semicolons in WPS Office VBA
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

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.

2
Locate the separator line

Find the line that appends the extracted address, such as outStr = outStr & Chr(10) & getStr or a similar line-break separator.

3
Replace it with conditional logic

Replace the separator line with: If outStr = "" Then outStr = getStr Else outStr = outStr & "; " & getStr End If.

4
Check the extraction loop

Verify that the loop appends each valid character to getStr and only adds the separator after a complete email address is built.

5
Save and test the macro

Save the VBA module, run the macro, and confirm the returned string is formatted as address1; address2; address3.

Use a Conditional Separator Block to Join Email Addresses
Clean result: This method prevents the final string from starting with "; " and works even when the output variable is initially empty.
WPS Office VBA Macro Solution

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. 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. 2. Locate the email extraction subroutine: In the VBA editor, find the subroutine that loops through text and builds the email address string.
  3. 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. 4. Save and run: Save the module, close the VBA editor, and run the macro to verify that the resulting string is semicolon-separated.
Edit VBA macros directly in WPS Office without leaving the applicationMaintains compatibility with Microsoft Office VBA-enabled .xlsm, .docm, and macro-supported filesFree, lightweight Office suite with a familiar VBA editor and macro workflowCleanly format extracted email addresses with a semicolon-space separator
microsoft office alternative - wps office

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.