Assign Email Addresses to Agents by Domain in WPS Spreadsheets
Question details
Assign email addresses to agent groups of up to five while keeping addresses with the same domain together where possible.

- Product
- WPS Spreadsheets or Microsoft Excel
- Device & OS
- not provided
- Scenario
- A spreadsheet contains email addresses from multiple domains that need to be divided into agent groups.
- Observed behavior
- Each domain should have its own groups of no more than five addresses, with a distinct group identifier for each assignment.
Place one valid email address per row in column C, starting at C2, and leave columns D through F available for helper formulas. The formulas assume each address contains an @ sign.
Group addresses by domain using helper columns
Use this method to create distinct agent groups of up to five for each domain, even when domains are mixed in the list.
The group identifier combines the domain with a number, so Agent 1 for one domain is distinct from Agent 1 for another. The last group for a domain may contain fewer than five addresses; this method does not combine remaining addresses from different domains.
In cell D2, enter =LOWER(TRIM(MID(C2,FIND("@",C2)+1,LEN(C2)))) to extract the domain after the @ sign.
In cell E2, enter =COUNTIF($D$2:D2,D2) to count how many times the current domain has appeared so far.
In cell F2, enter =D2&" - Agent "&ROUNDUP(E2/5,0) to assign each set of up to five occurrences to a domain-specific agent group.
Select D2:F2 and drag the fill handle down through the last row of email addresses. Use the identifiers in column F to assign each group to an agent.

Create domain-based agent groups in WPS Spreadsheets
Use WPS Spreadsheets formulas to extract email domains, count their occurrences, and create groups of up to five addresses for agent assignment.
- 1. Open the spreadsheet: Open WPS Spreadsheets and load your file, with email addresses in column C starting at C2.
- 2. Extract domains: Enter =LOWER(TRIM(MID(C2,FIND("@",C2)+1,LEN(C2)))) in D2.
- 3. Count occurrences: Enter =COUNTIF($D$2:D2,D2) in E2.
- 4. Create agent groups: Enter =D2&" - Agent "&ROUNDUP(E2/5,0) in F2, then select D2:F2 and drag the fill handle down to the last address.

Frequently Asked Questions
Do the email addresses need to be sorted by domain?
No. The COUNTIF formula counts earlier occurrences of the domain in column D, even when other domains appear between them.
What happens if a domain has fewer than five addresses left?
Those addresses form a smaller final group for that domain. The formulas do not automatically combine them with addresses from another domain.
How can I change the group size?
In the formula in F2, replace the 5 in ROUNDUP(E2/5,0) with the desired maximum group size, then fill the formula down again.
Why does the domain formula show an error?
Check the address in column C for a missing @ sign or a blank cell. The FIND function requires an @ sign to extract the domain.
Can I use these formulas in Microsoft Excel?
Yes. Enter the same formulas in columns D, E, and F in Excel, then use the fill handle to copy them down.




