% YES is hit formula

John Caines

Well-known Member
Joined
Aug 28, 2006
Messages
1,155
Office Version
  1. 2019
Platform
  1. Windows
Hello All.
I really would love to create a formula that simply tells me how many times a target is hit.
I have a column, (Column N), which can display the words "EVEN" or "YES" or "NO"

The formula runs from N24:N263. These are added usually daily, so at the moment I only have 30 entries out of the possible 240
As a note, the formula in cell N24 for example is;
Code:
=IF(LEN($M$24)=0,"",IF($M$24=$K$24,"EVEN",IF($M$24>$K$24,"YES","NO")))

What I'm looking to do is create a formula for cell P21,,, to display a % relating to column N
If the word displays YES or EVEN in a cell in column N,, this is a positive, only negative is the word NO.

Example.
If there were 10 entries in column N,
N24 shows "NO"
N25 shows "YES"
N26 shows "YES"
N27 shows "YES"
N28 shows "NO"
N29 shows "EVEN"
N30 shows "NO"
N31 shows "EVEN"
N32 shows "YES"
N33 shows "YES"

So P21 cell would like to now display 70% (As there were 7 positive events)

Trouble is, I don't know how to write this :-(
I've looked at a few formulas on my other spreadsheets, but I just can't work it out,, maybe it's a COUNTIF formula?,,, I'm not sure

If someone can help me with this I would be very grateful.

Many thanks for all your time.
A very confused.com,,,
John Caines :-)
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try
Code:
=COUNTIF(N24:N33,"<>NO")/10)

Change the ranges to suit and format the cell as %
 
Upvote 0
This will allow for the varied number of entries,

=SUM(COUNTIF(N24:N263,{"YES","EVEN"}))/SUM(COUNTIF(N24:N263,{"YES","NO","EVEN"}))

Format cell as %
 
Upvote 0
Thanks for your replies!!!
I was just trying Michael's formula,, and was writing a reply,, when I also saw your reply Jason,, many thanks.

Yes,, the problem was,, in adding entries etc,,,
Jason,, your formula seems to solve this !!
As a note,,, I noticed the use of {},,,,,,
Does this mean the formula is an array??

Just wanted to clarify.
Many thanks again,,,
I shall use this for 2 other cells also,, great stuff.

Many thanks
A very grateful.
John Caines :-)
 
Upvote 0
How do you want formula blanks that you have in column N treated?

1)

=SUM(COUNTIF(N24:N263,{"EVEN","YES"}))/ROWS(N24:N263)

treats formula blanks as no hit.

2)

=SUM(COUNTIF(N24:N263,{"EVEN","YES"}))/SUM(COUNTIF(N24:N263,{"EVEN","YES","NO"}))

disregards the formula blanks.
 
Upvote 0
As a note;
Formula now is;
Code:
=IF(LEN($M$24)=0,"",SUM(COUNTIF(N24:N263,{"YES","EVEN"}))/SUM(COUNTIF(N24:N263,{"YES","NO","EVEN"})))

Many thanks Jason!!! Working perfect,,,, great stuff!!! :-)

Just seen your reply also Aladin Akyurek,,, many thanks also,,, great minds think alike!!! :_)
one of your replies is the same as Jasons! :-)

The formula Jason (And now you) have supplied is the one,, works perfectly.
Many thanks for taking the time to answer,,, it is a very useful formula.

Thanks again
A very grateful
John Caines
 
Last edited:
Upvote 0
As a note;
Formula now is;
Code:
=IF(LEN($M$24)=0,"",SUM(COUNTIF(N24:N263,{"YES","EVEN"}))/SUM(COUNTIF(N24:N263,{"YES","NO","EVEN"})))

Many thanks Jason!!! Working perfect,,,, great stuff!!! :-)

Just seen your reply also Aladin Akyurek,,, many thanks also,,, great minds think alike!!! :_)
one of your replies is the same as Jasons! :-)

The formula Jason (And now you) have supplied is the one,, works perfectly.
Many thanks for taking the time to answer,,, it is a very useful formula.

Thanks again
A very grateful
John Caines

Doesn't just...

$M$24=""

suffice instead of

LEN($M$24)=0 ?
 
Upvote 0
Hi Aladin,,,,
you said about;
LEN($M$24)=0,,,,,,,,

I'm not an excel formula/coder/vba guy to be honest,,, just kind of scape through.

I remember requesting some help a while ago,, and someone kindly replied and mentioned this LEN part in a formula.
I'd never heard of it,, but I used it as in 1 sheet I had several different ways to do it,, IE COUNTBLANK or COUNTIF=5,,, or things like this,,,,, but I managed to replace them all with the LEN formula.

So,,, I'll carry on using it,,,,but,, do you think this is overkill?
I mean,,, is it asking excel to do a lot more in the formula?
So,, is $M$24="" just a more efficient way to do it then I suppose?

If it's ok (Seems to work ok),, I'll stick with the LEN,, as this is throughout my sheet in virtually all cells with formulas,,, just continuity really.

Thanks for pointing this out though.
I can't remember what it exactly does differently than most,,, but it works ok.

Many Thanks
John Caines
 
Upvote 0
There are a few things I can't make sense of John, for instance,

Code:
=IF(LEN($M$24)=0,"",IF($M$24=$K$24,"EVEN",IF($M$24>$K$24,"YES","NO")))

I would guess that in N25 this formula would be changed to

Code:
=IF(LEN($M$25)=0,"",IF($M$25=$K$25,"EVEN",IF($M$25>$K$25,"YES","NO")))

So why use absolute references and edit the formula each time when you could use relative reference and copy down?

An equivilant with a little less overkill would be

=IF(M24="","",LOOKUP(SIGN(M24-K24),{-1,"NO";0,"EVEN";1,"YES"}))

LEN($M$24)=0 LEN() counts the number of characters in the cell, so this is checking for a blank / empty cell, the same as Aladin's suggestion of $M$24=""
 
Last edited:
Upvote 0
Hi Aladin,,,,
you said about;
LEN($M$24)=0,,,,,,,,

So,,, I'll carry on using it,,,,but,, do you think this is overkill?
I mean,,, is it asking excel to do a lot more in the formula?
So,, is $M$24="" just a more efficient way to do it then I suppose?
Consider this...

A1 is an empty cell

=A1="" = TRUE
=LEN(A1)=0 = TRUE

A1 contains a formula that returns a blank ""

=A1="" = TRUE
=LEN(A1)=0 = TRUE

So, is it overkill? I think so.
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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