Function Problems

Assign Email Addresses to Agents by Domain in WPS Spreadsheets

Camila MilosovichCamila Milosovich Nov 18, 2026 870 views

Question details

Assign email addresses to agent groups of up to five while keeping addresses with the same domain together where possible.

Assign Email Addresses to Agents by Domain in WPS Spreadsheets
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.
Before you start

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.

Solution 1Recommended

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.

1
Extract the domain

In cell D2, enter =LOWER(TRIM(MID(C2,FIND("@",C2)+1,LEN(C2)))) to extract the domain after the @ sign.

2
Count each domain occurrence

In cell E2, enter =COUNTIF($D$2:D2,D2) to count how many times the current domain has appeared so far.

3
Create the group identifier

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.

4
Fill the formulas down

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.

Group addresses by domain using helper columns
Assigning actual agents: The formula creates group identifiers, not agent names. Match each distinct identifier in column F to an available agent.
Group email addresses in WPS Spreadsheets

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. 1. Open the spreadsheet: Open WPS Spreadsheets and load your file, with email addresses in column C starting at C2.
  2. 2. Extract domains: Enter =LOWER(TRIM(MID(C2,FIND("@",C2)+1,LEN(C2)))) in D2.
  3. 3. Count occurrences: Enter =COUNTIF($D$2:D2,D2) in E2.
  4. 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.
Keep each domain in separate groups of up to five addresses.Open and edit Microsoft Excel XLSX and XLS files.Fill formulas down to process a longer address list.Review group identifiers alongside the original addresses.
microsoft office alternative - wps office

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.