Formulate % with named range

The Grim Discovery

Board Regular
Joined
Jan 23, 2015
Messages
246
Office Version
  1. 365
Platform
  1. Windows
Hiya

This table is representative of a larger data set I'm working with. I want to calculate the number of yes / (yes+no)%. I wondered if I could use a named range by highlighting only rows of data which were relevant and ignore those that were blank or contained numerical .

But Excel didn't like my new formula (where namedrange is A1:G1, A3:G3 & A5:G5).

=(COUNTIF(namedrange,"yes")/(COUNTIF(namedrange,"yes")+COUNTIF(namedrange,"no"))%

Can this be done?
Thanks

[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]yes[/TD]
[TD]no[/TD]
[TD]n/a[/TD]
[TD]yes[/TD]
[TD]yes[/TD]
[TD]no[/TD]
[TD]n/a[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]25[/TD]
[TD]40[/TD]
[TD]46[/TD]
[TD]38[/TD]
[TD]71[/TD]
[TD]25[/TD]
[TD]47[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]yes[/TD]
[TD]no[/TD]
[TD]n/a[/TD]
[TD]n/a[/TD]
[TD]n/a[/TD]
[TD]yes[/TD]
[TD]yes[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]no[/TD]
[TD]n/a[/TD]
[TD]yes[/TD]
[TD]yes[/TD]
[TD]n/a[/TD]
[TD]no[/TD]
[TD]no[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
ignore those that were blank or contained numerical .

Hi, COUNTIFs() will ignore values that do not match the criteria so can't you just include the whole range. i.e.


Excel 2013/2016
ABCDEFGHI
1yesnon/ayesyesnon/a57%
225404638712547
3yesnon/an/an/ayesyes
4
5non/ayesyesn/anono
Sheet1
Cell Formulas
RangeFormula
I1=COUNTIFS(A1:G5,"YES")/SUM(COUNTIFS(A1:G5,{"Yes","No"}))
 
Upvote 0
FormR - cheers for that. But now realised that some rows of data contain 'Yes' and 'No's which I don't want to include the formula. Didn't spot that at the time of my original post.
 
Upvote 0
You can't use non-contiguous ranges with COUNTIFs() - is there anything about those rows that we use to logically determine if they should be included or not. Maybe some common text in a different column, or maybe it's every other row? or anything else?
 
Upvote 0
I'll have a look - got a feeling it's going to be horribly random. Thanks for your support and time with this.
 
Upvote 0
got a feeling it's going to be horribly random.

Maybe you could make use of a couple of helper columns to count a specific rows yes's and no's but only manually applied to the rows of interest. A tad messy but sounds like any alternatives might be even more so.

For example row 5 here would not contain the formulas:


Excel 2013/2016
ABCDEFGHIJKL
1Yes'sNo's
2yesnon/ayesyesnon/a3253%
3yesnon/an/an/ayesyes31
4non/ayesyesn/anono23
5non/ayesyesn/anono
6non/ayesyesn/anono23
Sheet1
Cell Formulas
RangeFormula
I2=COUNTIFS(A2:G2,"Yes")
J2=COUNTIFS(A2:G2,"No")
L2=SUM(I2:I6)/SUM(I2:J6)
 
Upvote 0
Maybe the formula below can help you:

=SUMPRODUCT((INDEX(namedrange,,,1)="Yes")+(INDEX(namedrange,,,2)="Yes")+(INDEX(namedrange,,,3)="Yes"))/
SUM(COUNTIF(INDEX(namedrange,,,
1),{"Yes";"No"})+COUNTIF(INDEX(namedrange,,,2),{"Yes";"No"})+COUNTIF(INDEX(namedrange,,,3),{"Yes";"No"}))

Markmzz
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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