Highlight values that are present in a range in another sheet - google-sheets

I'm making a Google Sheets that has a few pages, to keep track of turn-based game data. Right now, I have a sheet called Current which has a range (B5:J25) of values (all text). I have a second sheet (TurnActions) that has another range (B5:J25, again) of values.
Say the first sheet contains the values Finite, Alexander, and Trackpad in various locations, and the second contains Hamster, Finite, and Flow. I want Finite to be highlighted.
How would I use conditional formatting rules to add a red background to any values in the second sheet that are present in the first sheet?

Please try clearing formatting from and selecting TurnActions!B5:J25 and Format, Conditional formatting..., Format cells if... Custom formula is and:
=countif(importrange(" k e y ","Current!B$5:$J$25"),B5)>0
Then select red fill and Done.
A conditional format rule cannot reference a different sheet directly but we 'cheat' and use IMPORTRANGE to fetch what we need. Hence permission must be granted, to access the other sheet.
k e y is whatever is appropriate for your sheet Current.
Use delimiters appropriate for your locale.
COUNTIF

Related

Conditional formatting based on cells matching a column of another sheet

I've got a spreadsheet made on Google Sheets that contains 11 sheets, and each sheet is a set of things that I'm considering buying.
Some sets contain the same individual pieces as something else.
For example item A might be on sheet A and sheet D.
I'd like to make some kind of formula to highlight all duplicates, so that when I was looking through the sheet I could see whether buying item A will help me complete more than just the set that I'm looking at. So I can look at a set and if it's mostly green I know there's more value in buying it as almost all of the contents will also go towards another set.
I know how to do it so that they glow if they match on the same sheet.
$A2=$B2
However I'm not sure how to do it across sheets, or how I'd include if statements. As the colour would have to change if it matches any cells in column A on any sheet. They're also not in the same order on different sheets so while item A might be in A3 on sheet A, it might be in A17 on sheet D.
I'm not sure how possible something like this is, but I'd appreciate any help.
Google Sheets does not allow direct references to cells in other sheets in conditional formatting formulas. But this can be circumvented with indirect:
= A2 = indirect("Sheet2!A2")
formats the current cell (A2) if it's the same as the contend of A2 on Sheet2.
But you want to check whether the content is duplicated anywhere in column A of another sheet. This can be done with match: select the column A2:A of the present sheet, and add conditional formatting with custom formula
=match(A2, indirect("Sheet2!A2:A"), 0) > 0
Here match returns either the position of found element (a positive number) or #N/A, and the formula evaluates to True in the former case only.
Although the formula says "A2", it can be applied at once to any range that has A2 as its upper left corner.

Value contains many text in Conditional Format Rules Google Sheet

I want to set conditional format rules in my Google spreadsheet. For the format cell, I select "Text contains", then I type values "PA, MA, CT, NY", formatting style I choose red. When I click DONE, the columns containing these words didn't show the color. I don't want to create rules "PA', "MA", "CT"and "NY" one by one. How can I fix them? Thanks for helping.
Select the relevant range (I am assuming starts at A1) and clear any existing CF rules from it. Format, Conditional formatting..., Format cells if... Custom formula is and:
=regexmatch(A1,"PA|MA|CT|NY")
with red fill and Done.
This should format any cells that contain any of the four state abbreviations (that is, both as part of the content of a cell and as all the content of the cell). It should format PACT but being case sensitive not many.
Try using OR with custom formula like this:
=or($A2="PA",$A2="MA",$A2="CT",$A2="NY")
As Ed said, but to clarify,
Go to conditional format and select 'Custom formula'
Assuming that your values are in column A, set the range to A1:A and enter the formula =OR($A:A="PA",$A:A="MA",$A:A="CT",$A:A="NY") in the custom formula field.
If the values are not in column A then change the formula as necessary.

Change the background of one google sheets column based on the date in another column

I've seen lots of answers for various other conditions under which to do this. However I can't seem to modify any of these to work for a date range. What I want is for the column color of column E to change if the date in column H is between today and 5 days from today.
I've tried varying versions of this formula: H3:H150 =today() +5 with no success
This doesn't give me the range of between now and 5 days from now but I could do multiple rules like this and just go down on each one(=today() +4, =today() +3, etc) but obviously I need this rule to work first.
Thanks!
Conditional formatting is more helpful than you seem to be expecting. Clear formatting from the column to be formatted, select it and Format, Conditional formatting..., Format cells if... Custom formula is and:
=and(H1>today(),H1<today()+6,H1<>"")
Then select fill of choice and Done.
This should format the next five days (change the angled brackets around for the past five days).
Setting the range is achieved with selection of the column to be formatted (not the one with dates in it - H). If only to apply to Rows3:150 (and in general it is a good idea, for speed of processing, to restrict the ranges to which CF is applied) then either start by selecting Rows3:150 in the column to be formatted (instead of the entire column) or adjust the Apply to range for the rule, but in either case use H3 in place of H1 in the formula above.
CF should automatically apply the rule as written to the first row in the selected range and then adjust it for the second and subsequent rows in the way copying down would adjust the formula (if at all) were it in a cell in the sheet.

Google Sheets - How to highlight cells in a row that match values from other cells?

I have a row of values (say 1-10)
At the beginning of the rows I have 2 numbers generated from dates from other cells that represent week numbers. (eg, 3 and 9)
I want my row to highlight all the numbers from 1-10 that are between the values from the week number cells. (eg the cells with numbers 3,4,5,6,7,8 and 9 will automatically turn a colour (say green))
I've tried the conditional format, using the "between" values.
It doesn't work.
If I just type the numbers into the format box, it will work, but the problem is I need it to refer to the value in the cell NOT a number I type in, because there is a likelihood that the dates could change, which will affect the value shown in week number cell, so I need it to work automatically and not require me to go through every single row changing values for the formatting.
Is this even possible on sheets?
Thanks in advance, I am hoping I've just overlooked something simple.
Use a custom function for conditional formatting. For instance, if the columns you describe are in Row 2, this function will evaluate "TRUE" for numbers that are >= A2 and <= B2:
=AND(C2>=$A2,C2<=$B2)
Select the range of cells you wish to create a conditional format for; C2..L2, say. Open the conditional formatting dialog, and choose "Custom formula". Enter the formula above; note that itr refers to the top-left corner of the range you wish to apply the formula to - Sheets will automatically adjust it for the rest of the range, which is why it's important to use absolute references for the first two columns.

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