# countif with non-contiguous range

#### The Grim Discovery

##### Board Regular
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.

#### godsaaint

##### Active Member
Any reason why you can't just use "=COUNTIF(A1:A49,"Yes")"?

#### The Grim Discovery

##### Board Regular
Because that will include other 'yes's that I don't want to count ie in cells A14, A16 etc

#### Gerald Higgins

##### Well-known Member
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.

#### Marcelo Branco

##### MrExcel MVP
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.

#### The Grim Discovery

##### Board Regular
Thanks Marcelo - that's really appreciated.

#### Wad Mabbit

##### Board Regular
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.

#### mikerickson

##### MrExcel MVP
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")

Replies
5
Views
278
Replies
4
Views
154
Replies
2
Views
56
Replies
3
Views
80
Replies
5
Views
367

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

### 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