countif with non-contiguous range

The Grim Discovery

Board Regular
Joined
Jan 23, 2015
Messages
238
Office Version
  1. 365
Platform
  1. Windows
Good people

I want to count the number of 'yes' values in Col A. The cells I want to count are non-contiguous so I thought that if I defined them as named range 'ColA' and then in A50 where I want the result to populate "=COUNTIF(ColA, yes)" would work. It doesn't. At least it doesn't the way I'm attempting. Anyone care to lend a hand?

Several large thanks in advance.

[ColA range=A8:13, A15, A17, A19:25, A27:A28, A31:33]
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Gerald Higgins

Well-known Member
Joined
Mar 26, 2007
Messages
9,258
Is there any other data you can use, perhaps in a different column, to separate the "Yes"s that you want to count, from the "Yes"s that you don't want ?
If so, then you might be able to use COUNTIFS as opposed to COUNTIF.
 
Upvote 0

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
17,100
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
Maybe somnething like this

Create a named range, say, RngList (B2:B7)


B
1
RngList​
2
A8:A13​
3
A15​
4
A17​
5
A19:A25​
6
A27:A28​
7
A31:A33​

Then try this formula
=SUMPRODUCT(COUNTIF(INDIRECT(RngList),"Yes"))

Hope this helps

M.
 
Upvote 0

Wad Mabbit

Board Regular
Joined
Mar 31, 2016
Messages
72
Office Version
  1. 2016
Platform
  1. Windows
INDIRECT is volatile, is there an alternative?
At the moment I'm using
=(tblStudentProgress[@[D1 Participation]]="N")+(tblStudentProgress[@D2Participation]="N")+(tblStudentProgress[@D3Participation]="N")+(tblStudentProgress[@D4MSMWHS200]="N")+(tblStudentProgress[@D5Participation]="N")+(tblStudentProgress[@[D6 FSKOCM07]]="N")+(tblStudentProgress[@[D7 Participation]]="N")+(tblStudentProgress[@[D8 FSKDIG03]]="N")+(tblStudentProgress[@[10 FSKRDG05]]="N")+(tblStudentProgress[@[10 FSKLRG05]]="N")+(tblStudentProgress[@[11 FSKLRG09]]="N")+(tblStudentProgress[@[12 Participation]]="N")

Which is the neatest I can do at the moment.
 
Upvote 0

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,348
The argument of COUNTIF must be a contagious range.
To get the result you seek, you need to use COUNTIF(A8:13,"yes") + COUNTIF(A15, "yes")+COUNTIF(A17,"yes") +... +COUNTIF(A31:33,"yes")
 
Upvote 0

Forum statistics

Threads
1,190,631
Messages
5,982,035
Members
439,750
Latest member
megaman777

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
Top