Color Excel cell based on COUNTIF function - excel-formula

I'm trying to color excel cell based on my COUNTIF-function. There are many examples to count cell based on color but i need to fill cell with color based on COUNTIF-function. I have 30 names in a column. At the end i have COUNTIF-function to count total number of names with last name Malik. This works and i get number 8 from this function. Now I would like to highlight these 8 cells, so they are easy to find. If colorfill can be combined with COUNTIF-function, it would be the best.

conditional formatting -> formula -> =isnumber(search("Malik",a1;0)) should work. delete dollar signs for the search cell. Adapt the celladdress to your needs.
You could also use =COUNTIF(A1,"*Malik*") or even use =COUNTIFS(A1,"*Malik*",B1,"<"&today())

Related

Is there an excel formula that can check the number of words in consecutive cells and give an output based on conditions?

I am trying to create an output in excel based off the number of words in cells. Essentially i want to check if the sum of the words in 3 cells is = 1,2 or >=3. Im using the len formula which i have successfully used on single cell conditions but im struggling to create the formula that would check multiple cells.
Below is an example of my data:
Column A Column B Column C
Cat;dog Bird
Formula
=SUMIF(AND(LEN(TRIM(A4))-LEN(SUBSTITUTE(B4," ",""))+1, LEN(TRIM(C4))-LEN(SUBSTITUTE(C4," ",""))+1, >=3), "Titanium")
https://docs.google.com/spreadsheets/d/1W6nFr-W0r-XWZnvrFWndsvdBEEGHMQUa/edit?usp=sharing&ouid=103068518904190156690&rtpof=true&sd=true
First I made a single formula to work on a single cell. It ignores semicolons and commas to calculate total words. That formula is in column F and it's:
=IF(LEN(E5)=0;0;LEN(TRIM(SUBSTITUTE(SUBSTITUTE(E5;";";" ");",";" ")))-LEN(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(E5;";";" ");",";" "));" ";""))+1
Notice I added an IF to make sure that blank cells will count as 0 words (because the +1 will be added wrongly and we need to avoid this.
Now you just need to sum up all results and we get 8 words.
What you want is to get this result with a single formula and that can be perfomed with array formulas. In cell F11 my formula is:
=SUM(IF(LEN(E5:E8)=0;0;LEN(TRIM(SUBSTITUTE(SUBSTITUTE(E5:E8;";";" ");",";" ")))-LEN(SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(E5:E8;";";" ");",";" "));" ";""))+1))
You need to introduce this formula pressing CTRL+ENTER+SHIFT or it won't work!
Now you got the result in a single formula and you just need to add your conditions mentioned in your post
UPDATE: In your Google Sheets, the correct formula would be:
=ArrayFormula(IF(SUM(IF(LEN(TRIM(A3:B3))=0,0,LEN(TRIM(A3:C3))-LEN(SUBSTITUTE(A3:C3," ",""))+1))>=3,"Good","Bad"))
Please, notice Excel is not the same as Google Sheets so sometimes the formulas may be different in one of them.

Excel Conditional Formatting with updating formula

I have a matrix in excel (pictured below) that I need the following conditions for:
(1) A cell should be orange if a time fraction and Tj are provided on the same row, AND a Ball name is provided on its respective column
(2) A cell should be blue if, on the same row, any previous current input is <= .5* the first current input on the same row, regardless of if a ball name is provided
(3) A cell should be blue if no time fraction or Tj are provided on the same row, or if no ball name is given in its respective column
(4) The cells must default to blue when nothing is entered
At the moment, the cells are filled blue, so I understand that I need to only format when the cells should become orange, but I'm having some trouble working out the logic for conditional formatting, and as its a large table, I would like to avoid having to enter a conditional format for each individual cell.
Is there a way to say, for instance, (cell) = AND(tfrac <> "", tj <> "", Ballname <> "") format(orange), and then have the row/column numbers change for each cell, to that cell's respective column/row letter/number? Thanks!
If you are new to conditional formatting, you can follow this answer I gave to a different question: Is it possible to have excel highlight cells that don't conform to my desired format (ex. date as 6.2.2021 vs the desired 6/2/2021)? which will show you how to go about it.
As to the actual conditional logic for the formula that will be used, I would try something like:
=AND($time<>"", $tj<>"", ballname="what_you_want")

Get Count of Cells used in Excel Formula

I want to get the count of cells used in an excel function.
For example say I have a sum function ='CV'!D11+Farmer!D11+'County'!D11+Rt!D11+WT!D11+'Country'!D11
I need a function that will tell me how many cells were used to get the total sum. In this case it is 6. The tricky part is if one of the cells used is blank I do not want it counted. For instance say cell D11 on the Farmer sheet is blank I do not want it counted in the total. So the total should be 5.
Use COUNT:
=COUNT('CV'!D11,Farmer!D11,'County'!D11,Rt!D11,WT!D11,'Country'!D11)
It will only count the cell if it has a number
You should really try to collate all your data in to a single sheet before running calculations. For the sake of example, I'll assume you have it in the range A1:A5, then you can add handling of the various cases using array formulas:
Get the count of non-empty cells (the ISBLANK function is untrustworthy in my experience): {SUM(IF(LEN(A1:A5)>0,1,0))}
Get the sum of those cells: SUM(A1:A5)
(must use Ctrl+Shift+Enter to enter the formula as an array formula, you will know it worked if the formula shows like {IF(...)} with the curly brackets)
Because blank/missing values are treated implicitly as 0 in the SUM function, this case is simple. If you have other validations then you'd have to write an array formula for the summation as well. For example, only including numbers between a min and max threshold (e.g. if you want to exclude outliers):
{SUM(IF(AND(A1:A5 >= yourMinValue, A1:A5 < yourMaxValue), A1:A5, 0)}.
If I understand your question correctly, you want to literately count the number of cells used in a formula which in your example is summing 6 values from 6 different locations.
I used the following example to demonstrate my solution:
The sum of =A1+B1+C1+D1+E1+F1 is 10 where cell C1 has a 0 value in it but cell E1 is blank.
Using the following array formula I was able to count the number of cells that have a value other than 0:
=SUMPRODUCT(IFERROR(ABS(N(INDIRECT(TRIM(MID(SUBSTITUTE(RIGHT(FORMULATEXT(A3),LEN(FORMULATEXT(A3))-1),"+",REPT(" ",100)),100*ROW(INDIRECT("1:"&LEN(FORMULATEXT(A3))))-99,100)))))>0,0)*1)
Please note you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise they will not function correctly.
The logic is to use a combination of TRIM+MID+SUBSTITUTE+RIGHT+FORMULATEXT+REPT+ROW+INDIRECT to extract the cell addresses from the original formula, then use INDIRECT to convert the cell address into the values stored in those cells, then use a combination of IFERROR+ABS+N to find out if any of these values are not 0, and lastly use SUMPRODUCT to add up all the TRUE results.
It is obvious that there are a couple limitations of my solution:
If your actual formula is not strictly in the form of A+B+C+D+E+F, then my SUBSTITUTE part of formula will need further modification;
The formula will treat cells containing 0 as blank and does not include them in the count.
Let me know if you have any questions. Cheers :)

How can I automaticly color a cell based on another cells content that I know?

I´m trying to fill a Cell based on the words "beim Baum." which could appear in different cells in the same line. If this is true for any cell I want a particular cell to turn yellow. All cells contain words or numbers and are formatted as numbers.
So for example cell A1 contains "beim Baum." so I would like B1 to turn yellow. it should also turn yellow if C1 contains "beim Baum."
I know the conditional formatting formula for filling in a cell based on an exact word would be Rule $A1="beim Baum." Applies to =$B1, but this does not work.
I also tried: =SEARCH("beim Baum.",$B1)
and: =ISNUMBER(SEARCH("beim Baum.",$B1))
No matter which formula nothing happend
The ISNUMBER SEARCH approach is correct.
Lets have complete example:
Conditional formatting rule based on formula:
=ISNUMBER(SEARCH("beim baum",$A1&$C1))
is applied to =$B$1:$B$8.

Excel Conditional Formatting, Referencing 2 cells to the Right with conditions

I have a list of students who are between the ages of 3 and 5. lets say column A has the code, Column D has the childs age & Column F has their age group (3-5) If their age exceeds the age group then the Cell in column A will highlight Red. I am just not sure how to write this code correctly, all of the combinations i have tried come up with an error or just don't do anything.
IF(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5" & (OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5 {THEN FILL CELL RED} {ELSE NO FILL}
In the first part of the statement you are checking whether the cell 7 columns across = "3-5". You don't need to use offset for this, you can just reference the cell 7 across directly.
So if you're applying the conditional formatting to A1 that part of the formula would just be =IF(H1="3-5",{then},{else}).
If you just want TRUE or FALSE as the answer you don't need the IF statement, so this shortens to: =H1="3-5",
If you're applying the conditional formatting to a range instead of just an individual cell, say A1:B10, then you write the formula for the cell in the top left of the that range. So for A1:B10 you would still you the same formulae as above.
For the second part of the statement, using the same logic as above, you get: =E1>5
To check both statements together you need to wrap them in the =AND() function, giving you this as the final formula for your conditional formatting:
=AND(H1="3-5",E1>5)
By using the AND function I can achieve the desired result without cell references moving if a cell is relocated.
=AND(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5yo",OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5)

Resources