Ignore blank cells when using Sumproduct formula

jjwen

New Member
Joined
Jun 4, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi everyone, I have a problem when using Sumproduct formula:

In cell B16, I' m trying to count the number of cells where the value in Column B is less than or equal to the value in Column A, but only when there's a value in Column B.

1685852433904.png


For example, the value in B1, B2, B3, B4, B6, B12 and B14 is less than or equal to the value in A1, A2, A3, A4, A6, A12 and A14, so there's 7 cells in column B that meets the criteria, and it should return 7 in B13. However, if I use =SUMPRODUCT(--(A1:A15>=B1:B15)) to do the calculation, it will include blank cells in column B and return 13 in B13. Is there a formula to ignore the blank cells in column B? Thank you in advance for your help!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Book1
AB
131
222
343
465
57
644
78
85
934
106
1126
1297
137
1465
155
167
Sheet1
Cell Formulas
RangeFormula
B16B16=SUMPRODUCT((B1:B15<>"")*(B1:B15<=A1:A15))
 
Upvote 0
Welcome to the MrExcel board!

Another option might be to use some of the new functions available to you in MS365.

23 06 04.xlsm
AB
131
222
343
465
57
644
78
85
934
106
1126
1297
137
1465
155
167
COUNTIFS
Cell Formulas
RangeFormula
B16B16=LET(b,B1:B15,COUNT(FILTER(b,(b<>"")*(b<=A1:A15),"")))
 
Upvote 0
Just realised that with my count/filter suggestion, there is no need for the 'blank' check or for the 'if empty' filter provision. This does the same job.

23 06 04.xlsm
AB
131
222
343
465
57
644
78
85
934
106
1126
1297
137
1465
155
167
COUNTIFS
Cell Formulas
RangeFormula
B16B16=COUNT(FILTER(B1:B15,B1:B15<=A1:A15))
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top