Sumproduct with an IF statement

JTL9161

Active Member
Joined
Aug 29, 2012
Messages
340
I have this formula below. I need to add and if statement to it that if the total is less than 4 (<4) then just put an 0 but if 4 or greater (>4) then show the number.

=SUMPRODUCT(COUNTIF(R2:U2,B$192:Q$192))

Thank You,
James
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,204
Office Version
2007
Platform
Windows
Try this

=IF(SUMPRODUCT(COUNTIF(R2:U2,B$192:Q$192))<4,0,SUMPRODUCT(COUNTIF(R2:U2,B$192:Q$192)))

<tbody>
</tbody>

<tbody>
</tbody>
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,953
Office Version
365, 2010
Platform
Windows
or

=SUMPRODUCT(COUNTIF(R2:U2,B$192:Q$192))*(SUMPRODUCT(COUNTIF(R2:U2,B$192:Q$192))>=4)
 
Last edited:

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,953
Office Version
365, 2010
Platform
Windows
Sorry, I read that wrong. Please see edited formula above.

<b>Excel 2010</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th><th>M</th><th>N</th><th>O</th><th>P</th><th>Q</th><th>R</th><th>S</th><th>T</th><th>U</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">4</td><td style="text-align: right;;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">1</td><td style="text-align: right;;">2</td><td style="text-align: right;;">3</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">192</td><td style="text-align: right;;">4</td><td style="text-align: right;;">1</td><td style="text-align: right;;">3</td><td style="text-align: right;;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">J2</th><td style="text-align:left">=IF(<font color="Blue">SUMPRODUCT(<font color="Red">COUNTIF(<font color="Green">R2:U2,B$192:Q$192</font>)</font>)<4,0,SUMPRODUCT(<font color="Red">COUNTIF(<font color="Green">R2:U2,B$192:Q$192</font>)</font>)</font>)</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">K2</th><td style="text-align:left">=SUMPRODUCT(<font color="Blue">COUNTIF(<font color="Red">R2:U2,B$192:Q$192</font>)</font>)*(<font color="Blue">SUMPRODUCT(<font color="Red">COUNTIF(<font color="Green">R2:U2,B$192:Q$192</font>)</font>)>=4</font>)</td></tr></tbody></table></td></tr></table><br />
 
Last edited:

JTL9161

Active Member
Joined
Aug 29, 2012
Messages
340
My bad. All the numbers were 4 so they were not GREATER than 4. I changed the end to >=4 and it works.

Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,102,554
Messages
5,487,527
Members
407,604
Latest member
sama9000

This Week's Hot Topics

Top