Function Problems

Remove Excel Contact Rows by Company and Employee Count

Huda QurayshiHuda Qurayshi Nov 27, 2026 869 views

Question details

Keep a specified number of contacts per company based on the company's employee count and remove excess contact rows.

Remove Excel Contact Rows by Company and Employee Count
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet lists company names in column B and employee counts in column C, with a separate table defining how many contacts to keep for each employee-count range.
Observed behavior
The user needs to apply the employee-count limits to contacts grouped by company, rather than treating the number of contacts as the employee count.
Before you start

Confirm that company names are consistent and employee counts in column C are numeric and consistent for contacts at the same company. Decide which contacts should be kept first, and place the lookup table outside the data range.

Solution 1Recommended

Rank contacts and filter by employee-count limits

Use a lookup table and helper columns to identify contacts within each company's allowed limit.

This example assumes headers are in row 1, contacts start in row 2, and columns F through J are available. Adjust the references if your worksheet uses different columns.

The lookup uses the largest threshold that is less than or equal to the employee count. The example limits are 1 contact for 0–29 employees, 5 for 30–99, 10 for 100–249, 20 for 250–99,998, and 50 for 99,999 or more. Replace these thresholds and limits with your own rules.

1
Create the lookup table

Enter thresholds 0, 30, 100, 250, and 99999 in I1:I5, and their corresponding contact limits 1, 5, 10, 20, and 50 in J1:J5. Keep the thresholds in ascending order.

2
Sort the contacts

Select the contact table and use Data > Sort to sort by company name in column B. Add a secondary sort if a particular contact should be kept before others at the same company.

3
Rank each company's contacts

Enter 1 in F2. In F3, enter =IF(B3<>B2,1,F2+1), then fill the formula down to the last contact row.

4
Calculate limits and keep flags

In G2, enter =VLOOKUP(C2,$I$1:$J$5,2,TRUE). In H2, enter =F2<=G2. Fill both formulas down; column H shows TRUE for contacts within the limit and FALSE for excess contacts.

5
Filter the results

Select the contact table, choose Data > Filter, and filter column H for TRUE. Copy the visible rows to a new worksheet to create a list without the excess contacts.

Rank contacts and filter by employee-count limits
Deleting excess rows: If you prefer to delete rows in place, first copy the helper columns and use Paste Special > Values to freeze their results. Then filter column H for FALSE and delete the visible worksheet rows. This prevents the ranking formulas from changing during deletion.
Work with contact lists in WPS

Filter excess company contacts in WPS Spreadsheet

Use WPS Spreadsheet to rank contacts by company, look up limits from employee-count ranges, and filter the results before creating a cleaned list.

  1. 1. Open the workbook: Open WPS Spreadsheet and use Open to select your Excel contact workbook.
  2. 2. Set up and sort the data: Enter the employee thresholds and contact limits in I1:J5, then select the contact table and use Data > Sort to group company names in column B.
  3. 3. Add helper formulas: Enter 1 in F2 and =IF(B3<>B2,1,F2+1) in F3. Enter =VLOOKUP(C2,$I$1:$J$5,2,TRUE) in G2 and =F2<=G2 in H2, then fill the formulas down.
  4. 4. Filter and copy kept contacts: Use Data > Filter on the contact table, filter column H for TRUE, and copy the visible rows to a new worksheet.
Apply employee-count limits with VLOOKUP and helper columnsFilter contacts to keep only the permitted rowsOpen and edit Microsoft Excel XLSX and XLS filesWork with familiar spreadsheet formulas and sorting tools
microsoft office alternative - wps office

Frequently Asked Questions

Why must the lookup use column C instead of the contact rank?

Column C contains the company's employee count, which determines the applicable limit. Column F ranks the contacts listed for that company; it does not represent the employee count.

Why does the lookup table need to be sorted?

VLOOKUP with TRUE uses an approximate match. Keep the employee thresholds in ascending order so it can find the largest threshold that does not exceed the value in column C.

How can I choose which contacts are kept?

Use Data > Sort to group by company and add a secondary sort, such as contact priority. The first contacts in each company group are the ones marked TRUE, up to that company's limit.

Why should I freeze the helper formulas before deleting rows?

Deleting rows can recalculate the sequential ranks and change which contacts are marked TRUE or FALSE. Copy the helper columns and use Paste Special > Values before filtering for FALSE and deleting rows.