Google sheets - conditional formatting from other sheet - google-sheets

I have two spreadsheets (S1 and S2). I want to apply conditional formatting to column D from S1 such that:
if text from cell D1, D2,... from S1 is present in column A from S2, a cell is colored green
if text from cell D1, D2,... from S1 is not present in column A from S2, a cell is colored red
Could not get my mind around it, could you please help? I assume I must use a formula, but not sure how...

Select S1!D:D and (i) apply 'standard' red fill, (ii) Format > Conditional formatting..., Format cells if... Custom formula is and:
=match(D1,indirect("S2!A:A"),)
with green highlighting and Done.

you may wanna check this answer: https://stackoverflow.com/a/54910481/5632629
and to reference another sheet in conditional formatting you will need to use INDIRECT() - https://webapps.stackexchange.com/a/126045/186471

Related

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.

Google Sheets Conditional Formatting with Multiple Variables

Google spreadsheet conditional formatting: I want cell A1 to turn green if it is less than all of B1, C1 and D1.
I can get it to work if it is less than one of the other cells. How do I get it to work, where the condition is "if it is less than all of the other cells"?
Please try clearing formatting from and selecting ColumnA and Format, Conditional formatting..., Format cells if... Custom formula is and:
=A1<min(B1:D1)
Then select formatting of choice and Done.

google spreadsheet conditional formatting on a column

I have a set of data range from A to G for instance, at column G, I would like to format the cell as following
if the value of G2 is between C2 and D2, then the background color is green.
if the value of G3 is between C3 and D3, then the background color is green.
and so on for the next 500 rows
How may I do it in the latest google spreadsheet please?
Many thanks
In G2 select Conditional Formatting select custom formula and enter
=and(G2>C2,G2<D2).
Then select Apply to range and enter G2:G. It will work for all column G .
Since format the cell I assume only to apply to ColumnG. Please try selecting ColumnG and Format, Conditional formatting..., change G1: in start of Apply to range to G2: and for Format cells if... select Custom formula is and insert there:
=or(and(G2<C2;G2>D2);and(G2>C2;G2<D2))
select green fill and Done.
Change ; to , if required for your locale setting.
With text labels in Row1 it is usually simpler to select the entire column and write such a formula for Row1.

Conditionally format Google Sheets cell based on text in a different cell

I would like to format cell D2 based on text in C2. I would like D2 to be colored Red if C2 contains text from a drop down of "No" and be colored Green if the text is "Yes". I have tried custom formula containing =IF C2 ("Yes") which Google Sheets seems to accept but he result is not displayed at all.
Select D2 (or D2:D9 or D2:<somewhere further down>)
Choose Format ► Conditional Formatting
Format cells if... Custom formula is...        =C2="yes"
Formatting style - choose a green Fill and click Done.
Add new rule then repeat from step 3 with `=C2="no" and a red Fill.
        
Edit: Actually, if the cell is to have a background of white for anything other than "Yes", then you only need one rule: =C2="Yes" That is, if the default background for the entire sheet is white.
You must add two separate rules to cell D2, one for each color. The formula must look like this:
=$C$2="Yes"
And for anything other than "Yes"
=$C$2<>"Yes"

Conditional Formatting from another sheet

I'm trying to have a cell on Sheet A check if it's either > or < the value in a cell on Sheet B, then change its color accordingly. Under the custom formula I use: =A1>("SheetB!A1"), but it doesn't seem to work. I use the color Green for the > and the color Red for the <. Every time the rules are saved it will always display A1 on Sheet A in red.
Is the function wrong? Or is it not possible to have a Conditional Format even search across sheets?
For some reason (I confess I don't really know why) a custom formula in conditional formatting does not directly support cross-sheet references.
But cross-sheet references are supported INDIRECT-ly:
=A1>INDIRECT("SheetB!A1")
or if you want to compare A1:B10 on SheetA with A1:B10 on SheetB, then use:
=A1>INDIRECT("SheetB!A1:B10")
=A1>INDIRECT("SheetB!"&CELL("address",A1))
applied to range A1:B10.
You can do this by referencing the cell and row number in the current sheet, so as you drag-copy that conditional formatting to other rows it will reference the correct cells.
In the below equation I am coloring cells based on the exact same cell in some other sheet named "otherSheetName" in this example. If for example you want to color cell B2 in Sheet2 if the cell B2 in otherSheetName contains the text "I Like Dogs" you would go to cell Sheet2!B2 , click condition formatting, choose equation from the drop down and paste the below equation.
=IF(INDIRECT("otherSheetName!"&ADDRESS(ROW();COLUMN()))="I Like Dogs";1;0)
Comparing strings instead of numbers for a conditional formatting rule, you can use:
=EXACT(A1,(INDIRECT("Sheet2!A1")))
Case sensitive.
There is one trick/bug: if you have conditional formatting in Sheet1 that explicitly references itself (e.g., the formula is Sheet1!$C$2), you can copy the conditional formatting to Sheet2 with Paste special > conditional formatting and it will "work"... as long as you don't touch anything:
if you try to edit the conditional formatting in Sheet2, then you'll get an "Invalid formula" error.
if columns/rows change in Sheet1 such that they affect the conditional formatting (e.g., row/column inserts), this is not reflected in Sheet2 (keep in mind that the indirect trick mentioned by #AdamL will also not reflect column/row updates either, so it's a wash in this respect).
I was able to compare two sheet and highlight the differences on the second sheet using conditional formatting :
=A1<>(INDIRECT("Sheet1!"&Address(Row(),Column(),)))

Resources