Counting certain text in a selection

28creation

Board Regular
Joined
Oct 13, 2014
Messages
124
Hi all,


I've got this code, & it's not bringing back the results I'm after.

=(IF(OR(COUNTIF(K7:M28,"No - Major")>0,1,COUNTIF(K7:M28,"No - Minor")>2,2),""))


K7-M28 are the cells (columns K, L & M are merged cells on each row).

Basically if any of these cells have a "No - Major" in them then the result in K29 should be 1, but if any have "No - Minor" three times or more than this should result in a 2.


Hope you can help!

Thanks.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try:
Code:
If(COUNTIF(K7:M28,"No - Major"),1,IF(COUNTIF(K7:M28,"No - Minor") > 2,2),""))
 
Upvote 0
Hi

If you look at your OR() function you will probably see where you've gone wrong:
=(IF(OR(COUNTIF(K7:M28,"No - Major")>0,1,COUNTIF(K7:M28,"No - Minor")>2,2),""))

What I would do is use a nested IF() like this - note that this way round means the 1 takes priority over the 2:

=IF(COUNTIF(K7:M28,"No - Major")>0,1,IF(COUNTIF(K7:M28,"No - Minor")>2,2,""))

Hope that helps

Mackers

Edit: Jack got there first, darn :)
 
Upvote 0
Thanks Mackers that works great.

If realised I need something a little different, my error, apologies.

I need one or two "No - Minor"s to result in a 2, but three or more to result in a 1.

Thanks.
 
Upvote 0
Try:
Code:
=IF(COUNTIF(K7:M28,"No - Major"),1,LOOKUP(COUNTIF(K7:K28,"No - Minor"),{0,1,2,3},{0,2,2,1}))
 
Upvote 0
Typo I think, try:
Rich (BB code):
=IF(COUNTIF(K7:M28,"No - Major",1,LOOKUP(COUNTIF(K7:M28,"No - Minor"),{0,1,2,3},{0,2,2,1}))
 
Upvote 0
Rich (BB code):
=IF(COUNTIF(K7:M28,"No - Major"),1,LOOKUP(COUNTIF(K7:M28,"No - Minor"),{0,1,2,3,},{0,2,2,1}))
 
Upvote 0
Had to take the comma out after the 3. Works great thanks.

Sorry, can another thing be added please?

If this criteria is successfully avoided the result should be a 3. So no "No - Minor" or "No - Major" at all (forgot to mention this earlier, apologies).
 
Upvote 0

Forum statistics

Threads
1,214,877
Messages
6,122,051
Members
449,064
Latest member
scottdog129

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