Custom Formula Google Spreadsheet - google-sheets

I want to change format of cell A1 colored green , depends on the value in cells (A2:A5) if all cells value is "Done" , I want to color A1 Green.

Approach:
Now you are checking only the cell A2. You should check all the column range.
Your idea is to make your header green when all the cells contain the word "Done". You can translate this idea to: I have exactly 0 cells that don't contain the word "Done". This way you won't have to keep track of how many cells are in your column.
You can count how many values respect a criterion using the function COUNTIF.
Formula:
=COUNTIF(A2:A5, "<>Done") = 0

Related

Conditional formatting if cells in row are less than header

I am trying to find a way to have a cell in column A turn yellow if any cell in the adjacent row is less than the value of its corresponding header. Please see my example sheet.
I'm trying to use this formula for my conditional formatting: =COUNTIF(B5:5,"<"&B$4)>=1 but I believe it's stuck on using Cell B4 as the header value for the entire range (instead of C4 for column C, D4 for column D, etc).
Any ideas on what I'm missing here?
For the red option, as you suggested, you should use:
=COUNTIF($B5:$H5,"")
But you may keep it that option above, so it is red even if there's an orange
Then, for yellow you can use:
=COUNTIF(BYCOL($B5:$H5,LAMBDA(each,each<OFFSET(each,4-ROW(each),0))),TRUE)
It checks in each column if the value is smaller than in row 4, and counts the amount of TRUE values
And green should be by default, I understand. Is it useful?

Conditional formatting based on adjacent cell value even when the first adjacent cell in row is blank

I would like to colour cell C3 red, as the value is less than the next filled cell on row 3 (E3).
You need custom formula in the formatting rules for range C2:W.
And you can use the formula below for green:
=and(not(isblank(C2)),C2>index(filter(D2:$W2,arrayformula(not(isblank(D2:$W2))))),1,1)
And make another conditional formatting rule with the same range and change > accordingly for red.
Note that the equal case does not have formatting in your example.
To understand why, there are a few components at work. I'll give an outline in case OP or any passer-by wants one.
First is how conditional formatting in Google Sheet works. I will be brief here. The range we put in the rule is C2:W. Google Sheet will use the beginning cell in that range as a reference. For C2:W, the 1st cell is C2. In the formula, the cells are read in terms of relative position to that reference cell. So when evaluating formatting for cell C2, it treats the formula as is. But, for example, when evaluating formatting for cell C3, Google Sheet iterates all non-fixed ranges by 1 row. Another example: for D3, all non-fixed ranges are iterated by 1 row and 1 column.
Whenever the formula evaluates to true, the format will be applied -- although that is subject to further formatting if you have subsequent formatting rules which apply to the given cell.
Next are the components of the conditional formula.
not(isblank(C2)) checks for blank cells and makes the whole formula only true when the cell is non-blank.
For filter() usage, please consult official documentation. I will explain how filter() is applied to your example.
In our use, we are trying to rid of empty cells in the range that is on the same row as the cell in question and goes from the next column to column W. (I am using column W because there is no known end column in your image. Please adjust to your application accordingly.) Same row as C2 means row 2. Hence the digit 2 in D2:$W2. No $ sign for row because row index is meant to iterate through our range C2:W in the formatting rule. No $ sign for D because we mean 1 column next to the cell in question and the exact column index should iterate. We fix column W because the end column does not evolve and is thus not meant to iterate. Neglecting this will not particularly change the result in your example. However, it is good to be clear with the meanings.
arrayformula(not(isblank(D2:$W2))) produces a local row array whose cells are true/false that each represents whether the corresponding cell is non-blank. filter() in turn only keeps cells from D2:$W2 for cells in arrayformula(not(isblank(D2:$W2))) that are true.
We only care about the 1st non-blank cell. To retrieve the 1st cell from a (local) array, we use index(...,1,1). (That said, omitting index() also happens to work for the 1st cell in particular because when comparing a single cell with > or < to an array range, only the 1st cell of the array is used.)
Apply a conditional formatting to the range desired (starting from cell C2) using this formula:
=IF(C2="",FALSE,OFFSET(C2,0,AGGREGATE(15,6,(COLUMN(D2:W2)-COLUMN(D2)+1)/(D2:W2<>""),1))>C2)

how to do the conditional formating for based on the limit of the characters in google sheet

I want to have conditional formating based on the length of the chars of the cells in the column.
if the length>100 then mark it red and possibly in another cell, count how many reds or how many cells are length > 100.
How can i do it?
The LEN function allows you to get the length of a string in a cell. For example if the cell A3 contained "hello", LEN(A3) would output 3.
To make the cell red, you can right-click on the cell and select conditional formatting. Then under the "Format cells if" select custom formula. You can then use =LEN(CELL_NUMBER)>100 as the formula and select red as the color to set it as.
You can also use the COUNTIF() to get the total count of cells with length greater than 100. Example usage is here: https://support.google.com/docs/answer/3093480?hl=en

Google Sheets conditional formatting doesn't apply to the whole range

I am trying to conditionally format a range of cells based on the value of a different cell. I have selected the range of cells, chosen "custom formula" and entered =reference cell="reference value". (see screenshot) this should make the whole range of cells purple if cell G4 equals the letter M. The problem is only the top-left cell in the range is changing color, not the whole range.
Also, I want to drag this block of cells down to repeat it, and for the conditional formatting to fill down appropriately (i.e. to reference cell G21 when I fill downwards and so on.) How do I do that?
you need to lock it down with $
try:
=$G$4="M"
or:
=G$4="M"

How Do I Highlight a Cell a Certain Color if the values in two other cells match?

I'm trying to get a cell to highlight with a certain color if the text of two other cells match. Has anyone else done this?
Example:
If the value in the cell A2 is "Car" and the value "Car" is in a range on another sheet, can the cell B2 be filled with a color?
Assuming a range on another sheet is ColumnC of Sheet2, then select B2, apply the Conditional Formatting custom formula:
=match(A2,indirect("Sheet2!C:C"),0)
and certain colour fill.
This can be achieved using conditional formatting.
Select the cell (B2 in your example) and in the menu bar go to Format > Conditional Formatting...
Here you want to use a custom formula. Specifically for your example, the formula to input would be:
=AND(A2="Car",COUNTIF(C2:C5,"Car")>0)
Note that the range that is being checked for "Car" is C2:C5, since you didn't specify any for your example.
EDIT:
Following the discussion in the comments:
=COUNTIF(Sheet2!$C:$C,A2)>0
What this does, is that it looks for the value in A2 in column C in Sheet2 and if it occurs once or more, the cell that you have applied this conditional formatting to, will be coloured.

Resources