IF and CountIf

junniec

New Member
Joined
Aug 6, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
This is my formula =IF(COUNTIF(B$6:B$21,"*"&$A6&"*"),"","Free"). Instead of showing nothing if CountIf returns 1, I'd like to show the value of the cell. Because it is a range, I'm not sure how to show just the value of the cell where it matches my condition. Kindly advise. Thanks a lot!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You're missing part of the IF

eg. if 1 = 1 then return 1 else o
IF(1=1,1,0)

Since COUNTIF returns a number you have something like =IF(1,1,0) you need 1 to equal something or be greater than or less than etc.

Maybe show some dummy data and what you want the result to be.
 
Upvote 0
you need 1 to equal something or be greater than or less than
You don't really since Excel treats zero as a False condition and any other number as a True condition

@junniec
Welcome to the MrExcel board!

See how this goes.

=IFERROR(INDEX(B$6:B$21,MATCH("*"&$A6&"*",B$6:B$21,0)),"Free")
 
Upvote 0
Hi mrshl, here's the image. The goal is to fill up the yellow boxes with the subjects when the teachers are teaching. The current formula shows only the "Free" text. Thanks.
 

Attachments

  • CountIf.png
    CountIf.png
    8.6 KB · Views: 6
Upvote 0
It seems that your data and/or layout is not realistic. If it was, all you need is this

20 08 07.xlsm
ABCDEFGHIJKLMN
6JaneEnglish/.JaneEnglish/.JaneJane  FreeFreeFree
7EstherBusiness/EstherBusiness/EstherEstherFreeFreeFree  
8AlvinMaths/AlvinMaths/AlvinAlvin FreeFreeFree 
Free
Cell Formulas
RangeFormula
I6:I8I6=B6
J6:N8J6=IF(C6="","Free","")



What about some more realistic (varied) sample data and layout and expected results with XL2BB so we can see clearly where the data and results are and don't have to manually type out the data to test with? :)
 
Upvote 0
You don't really since Excel treats zero as a False condition and any other number as a True condition

@junniec
Welcome to the MrExcel board!

See how this goes.

=IFERROR(INDEX(B$6:B$21,MATCH("*"&$A6&"*",B$6:B$21,0)),"Free")

This seems to be working ! Thanks Peter!
 
Upvote 0
It seems that your data and/or layout is not realistic. If it was, all you need is this

20 08 07.xlsm
ABCDEFGHIJKLMN
6JaneEnglish/.JaneEnglish/.JaneJane  FreeFreeFree
7EstherBusiness/EstherBusiness/EstherEstherFreeFreeFree  
8AlvinMaths/AlvinMaths/AlvinAlvin FreeFreeFree 
Free
Cell Formulas
RangeFormula
I6:I8I6=B6
J6:N8J6=IF(C6="","Free","")



What about some more realistic (varied) sample data and layout and expected results with XL2BB so we can see clearly where the data and results are and don't have to manually type out the data to test with? :)
I'd love to upload the actual excel file too but it did not allow me to, sorry as this is my first post! Love the prompt support the team is giving here. I've got the solution from Peter for now, thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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