VBA & Macro Problems

Use WPS Spreadsheets VBA to Send PDF Attachments Grouped by Cell Values

Rana GarciaRana Garcia Nov 13, 2026 869 views

Question details

The user needs a VBA macro in WPS Spreadsheets to group rows by the value in column C and send one email per group, attaching all PDF file paths stored in column G to the recipient address in column F.

Use WPS Spreadsheets VBA to Send PDF Attachments Grouped by Cell Values
Product
WPS Spreadsheets
Device & OS
not provided
Scenario
The user has a worksheet where each row contains a grouping value in column C, a recipient email address in column F, and a PDF file path in column G. They want to automate sending grouped PDF attachments by email.
Observed behavior
Rows that share the same column C value should produce one outgoing email to the column F recipient with every matching PDF path from column G attached.
Before you start

Check that your worksheet uses column C as the group key, column F as the recipient email address, and column G as the full PDF file path. Enable macros in WPS Spreadsheets and confirm that your email application, such as Outlook, is installed and can send mail.

Solution 1Recommended

Group rows by column C and send one email with all matching PDF attachments using VBA

Use this VBA approach when you need to send multiple PDF files to the same recipient in a single email and the file paths are stored in column G.

The macro reads each row, creates a dictionary key from the value in column C, and stores the matching PDF paths from column G. After all rows are processed, it creates one email per group using the recipient address in column F and attaches every PDF in that group.

1
Open the VBA editor in WPS Spreadsheets

Open your workbook in WPS Spreadsheets and press Alt+F11 to open the VBA editor.

2
Insert a new module

In the VBA editor, click Insert > Module to create a new standard module for the macro.

3
Paste and adjust the grouping code

Paste VBA code that groups rows by column C, stores column G PDF paths, and reads the recipient address from column F. Change the column letters or email subject if your workbook layout differs.

4
Run the macro and confirm the emails

Press Alt+F8, select the macro from the list, and click Run. Verify that one email is created for each unique column C value and that all listed PDFs are attached.

Group rows by column C and send one email with all matching PDF attachments using VBA
Expected result: One email is created per unique column C group, with all matching PDF files from column G attached to the recipient address in column F.

Automate Grouped PDF Email Attachments in WPS Spreadsheets

Open the VBA editor in WPS Spreadsheets, run a macro that groups rows by the column C value, and send one email per group with every PDF path from column G attached to the address in column F.

  1. 1. Open WPS Spreadsheets and the VBA editor: Launch WPS Spreadsheets, open the target workbook, and press Alt+F11 to enter the VBA editor.
  2. 2. Insert a module: In the VBA editor, go to Insert > Module to create a new module where the grouping macro will be stored.
  3. 3. Paste the grouping and email macro: Paste the VBA code that loops through the used range, groups rows by column C, collects PDF file paths from column G, and reads the recipient address from column F.
  4. 4. Run the macro: Close the VBA editor, press Alt+F8, select the macro, and click Run. Review each prepared email in your mail client before sending.
Groups worksheet rows automatically instead of sending one email per row.Attaches all matching PDF files from column G to a single email per group.Keeps .xlsx and .xlsm workbook compatibility with Microsoft Excel.Uses the familiar VBA editor and ribbon interface in WPS Office.Free to download and use for everyday spreadsheet automation.
microsoft office alternative - wps office

Frequently Asked Questions

What does the VBA macro do when several rows have the same value in column C?

It groups those rows into one dictionary key, collects every PDF path from column G for that group, and creates one email to the column F recipient with all of them attached.

Which columns do I need to change if my recipient or file path is in a different column?

In the VBA code, update the column references for the group key, recipient email, and PDF path respectively. For example, change the C, F, and G column assignments to match your actual worksheet layout.

Does this automation work in WPS Spreadsheets with Outlook?

Yes. WPS Spreadsheets can use VBA to automate Outlook if Outlook is installed and configured as the default mail client. You may need to enable the Outlook object library reference in the VBA editor under Tools > References.

Why are duplicate PDF attachments appearing in the same email?

Duplicates usually occur when the same file path appears more than once in column G for the same column C group. Use a collection that checks for existing paths, or clean duplicate rows before running the macro.

Can I send the emails directly instead of just displaying them?

Yes. If your VBA code calls the Send method instead of Display, Outlook will send the messages immediately. Keep Display while testing so you can review recipients and attachments first.