Function Problems

Count Values Under a Selected Column Header in Excel

Natalie TaylorNatalie Taylor Nov 25, 2026 870 views

Question details

Count occurrences of a value under the column header matching a selected name.

Count Values Under a Selected Column Header in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Names appear across column headers, dates run down rows, and a reporting cell contains the name to match.
Observed behavior
The desired formula counts cells containing W in columns whose header matches the selected name.
Before you start

Identify the header row, the data range beneath it, and the cell containing the selected name. Make sure the header and data ranges cover the same columns.

Solution 1

Use SUMPRODUCT to count values under a matching header

Use this formula when the headers, data, and selected name are on the same worksheet.

1
Enter the selected name

Enter the name to match in cell A6. This example uses headers in A1:C1 and data in A2:C4.

2
Enter the formula

Select an empty result cell and enter =SUMPRODUCT(($A$1:$C$1=A6)*($A$2:$C$4="W")), then press Enter.

3
Adjust the ranges

In the formula bar, replace A1:C1 and A2:C4 with your header and data ranges, and replace A6 or "W" if your name cell or target value differs.

Matching headers: If the same name appears in multiple headers, the formula counts W values under all matching columns. It does not filter by date.
Count by column header in WPS

Count values under matching headers in WPS Spreadsheets

Use SUMPRODUCT in WPS Spreadsheets to match a selected name against column headers and count the corresponding W values.

  1. 1. Open the workbook: Open WPS Office, choose Spreadsheets, and open the workbook containing your headers and data.
  2. 2. Enter the name: Enter the selected name in A6, assuming the headers are in A1:C1 and the data is in A2:C4.
  3. 3. Add the formula: Select an empty cell and enter =SUMPRODUCT(($A$1:$C$1=A6)*($A$2:$C$4="W")), then press Enter.
  4. 4. Save the result: Check the count and use File > Save to save the workbook.
Count values across columns that match a selected headerReference source data on another worksheetOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Can I count a value other than W?

Yes. Replace "W" in the formula with the value you want to count, such as "P".

How do I use a sheet name that contains spaces?

Enclose the sheet name in single quotes in each range reference, for example, 'Data Sheet'!$A$1:$C$1.

What happens if more than one column has the selected name?

SUMPRODUCT counts matching values under every column whose header matches the name in A6.

Do I need to use a special array-entry shortcut?

No. Enter the SUMPRODUCT formula in the result cell and press Enter.