Excel: Count Rows Where Column B Is Greater Than Column A
Question details
Count the rows in which a value in Column B is greater than the value in Column A on the same row.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user needs to compare two equal-sized ranges row by row and return the number of matching comparisons.
- Observed behavior
- The desired result is a count of rows where the Column B value exceeds the corresponding Column A value.
Make sure the two ranges start and end on the same rows, such as A4:A8 and B4:B8. Use numeric values in both columns so blank cells or text do not affect the comparison unexpectedly.
Use SUMPRODUCT to count row-by-row comparisons
Use this method in Excel versions that support SUMPRODUCT; it counts every row where Column B is greater than Column A without requiring a special array entry.
SUMPRODUCT evaluates the comparison for each pair of cells, converts TRUE results to 1, and adds them together.
Click an empty cell where you want the count to appear, such as D4.
Type =SUMPRODUCT(--(B4:B8>A4:A8)) and replace B4:B8 and A4:A8 with your matching data ranges.
Press Enter to calculate the count. For the example ranges, the formula returns 3 when three values in Column B are greater than their corresponding values in Column A.

Use a dynamic array SUM formula in newer Excel
Use this formula when your version of Excel supports dynamic array calculations and you prefer a concise alternative.
Count Corresponding Column Values with WPS Spreadsheets
WPS Spreadsheets lets you compare values in corresponding rows and count matches with the SUMPRODUCT formula. Open an Excel workbook, enter the formula in an empty result cell, and WPS calculates the total while preserving your worksheet layout.
- 1. Open the workbook in WPS Spreadsheets: Launch WPS Office, choose Spreadsheets, and open the .xlsx or .xls file containing Columns A and B.
- 2. Select the result cell: Click an empty cell where the comparison count should be displayed.
- 3. Enter the comparison formula: Type =SUMPRODUCT(--(B4:B8>A4:A8)), adjusting both ranges to cover the same rows in your sheet.
- 4. Calculate and review the result: Press Enter to display the number of rows in which the Column B value is greater than the matching Column A value.

Frequently Asked Questions
What formula counts rows where B is greater than A in Excel?
Use =SUMPRODUCT(--(B4:B8>A4:A8)). Change both ranges to match your data rows, and keep the ranges the same size.
Why must the Column A and Column B ranges have the same number of rows?
The formula compares cells by position, such as B4 to A4 and B5 to A5. Unequal range sizes can produce an error or an invalid comparison.
Can I use COUNTIFS to compare one range directly with another range?
SUMPRODUCT is the reliable choice for row-by-row range comparisons. COUNTIFS is primarily designed for criteria applied to ranges and may not evaluate a second range as a row-matched criterion in all Excel versions.
How do I ignore blank cells when comparing Columns A and B?
Add nonblank tests to the formula: =SUMPRODUCT(--(B4:B8>A4:A8),--(A4:A8<>""),--(B4:B8<>"")). This counts only rows where both cells contain a value.




