How to Count X Marks by Row in an Excel Matrix
Question details
The user needs a way to count how many cells in each row of a matrix contain an 'X' to display a row subtotal, as well as a method to calculate a grand total.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking attendance, processing survey responses, or evaluating checklist completions where 'X' is used as a marker within a data grid.
- Observed behavior
- Requires an automated formula to replace manual counting of 'X' entries across multiple rows and columns.
Ensure your data matrix is properly aligned and check that your 'X' marks do not contain accidental leading or trailing spaces, as hidden spaces can prevent formulas from counting the cells correctly.
Use the COUNTIF Function to Count 'X' Marks
The COUNTIF function is the most direct and efficient method for counting cells that meet a specific text criteria, such as containing an 'X', across specified rows or matrices.
The COUNTIF formula allows you to set a specific range (like a single row) and a condition (like the letter 'X'). It will automatically tally every instance where the condition is met.
Click on the empty cell at the end of your first data row (for example, cell G2) where you want the subtotal for that row to be displayed.
Type the formula =COUNTIF(B2:F2, "X") into the formula bar, replacing B2:F2 with the actual range of your row data. Press Enter to see the row total.
Click on the cell containing your new formula. Click and hold the small square at the bottom-right corner of the cell (the fill handle), and drag it down to apply the formula to the rest of the rows.
To find the total number of 'X' marks across the entire matrix, select a cell below your data set and enter =COUNTIF(B2:F20, "X"), adjusting the B2:F20 range to cover your complete matrix.

Easily Count Data and Use Formulas in WPS Spreadsheet
WPS Office provides a highly compatible and feature-rich Spreadsheet application that perfectly supports COUNTIF, SUMIF, and all standard data functions. It makes managing attendance matrices and data tracking effortless.
- 1. Open your matrix in WPS Spreadsheet: Launch WPS Office and open your spreadsheet document containing the data matrix.
- 2. Input the COUNTIF formula: Click the cell where you want the row total, type =COUNTIF(B2:F2, "X") and hit Enter.
- 3. Drag to fill: Use the fill handle in the bottom-right corner of the cell to drag the formula down to calculate totals for all rows instantly.

Frequently Asked Questions
Why is my COUNTIF formula returning 0 instead of the correct count?
This usually occurs if the formula references the wrong range or if the cells contain the 'X' mixed with hidden spaces. Check for trailing spaces in your cells, or update your formula to =COUNTIF(B2:F2, "*X*") to count the letter regardless of surrounding spaces.
Can I count multiple different characters, like 'X' and 'Y', in the same row?
Yes, you can combine multiple COUNTIF functions. Simply add them together in the same cell using a plus sign, for example: =COUNTIF(B2:F2, "X") + COUNTIF(B2:F2, "Y").
Is the COUNTIF function case-sensitive?
No, COUNTIF is not case-sensitive. It will count both uppercase 'X' and lowercase 'x' as identical entries. If a strict case-sensitive count is required, you must use an array formula combining the SUM and EXACT functions.




