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

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.

Related

Limit Number of Cells with the Same Value in Google Sheets

I'm looking to limit the number of cells that can have the same value in a column.
More precisely, I'm keeping track of people signed up for meeting dates and once four other people are assigned that date, it not to be an option anymore or highlight the cell in red? Something to alert that the meeting is already full.
Thanks in advance for any help or advice.
If highlighting the cell in red would be enough, then you can use this custom formula in your Conditional Format Rules.
Apply to range = A1:A
Custom Formula:
=countif(A:A,A1)>=4
What it does?
Increment a counter if duplicates are found in the given range using COUNTIF()
If the number of duplicates are >= 4 then set the background color of the cell to red
Sample:
Another variation if you have a different list of available dates to highlight and a list of booked dates
Apply to range = A1:A
Conditional Formatting Custom Formula:
=countif(C:C,A1)>=4
Highlighting of cells will only be applicable in Column A. It will check how many duplicates data in Column A exist in Column C using COUNTIF()

Google Sheets Conditional Formatting based on two cells having matching numbers

I would like to highlight every row where the numbers in Columns F and G match. This works perfectly, with text (a-z), as answered in this thread:
Google Sheets Conditional Formatting based on two cells
But, I am not sure how to make it work when it's a number. Any advice appreciated!
Apply custom-formula conditional formatting of =$F1=$G1 to the whole range you wish to affect.
Change the 1's to the row number that is the first row in your selected range. E.g. If applying to A5:H, the formula would be =$F5=$G5.

Format one row as soon as cumulative sum reaches a particular number

I have a Google sheet that shows the number of KM a vehicle ran every day. Column E is the total distance. I want to change row background to red as soon as the value in E crosses 1000. And it should apply only to that one immediate row.
How to do it?
Select A5 to wherever suits, and apply a Conditional formatting formula rule of:
=countif($E$5:$E5,">1000")=1
You can do this directly with a formula from the Conditional Formatting option.
In my example I am shading the row in the area A1:B3 based on the values in C
Use the format cells if ... custom formula is option and put the conditions you want you range to change in there.
E.g. I am formatting my range to change to green when =$C1>=1000
Notice I don't need to change C1 to include all the rows, as it will evaluation on every for separately.

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.

How do I change the row that numbers are compared based on the data in another cell?

I am usually good with conditional formatting in excel/google sheets, but here is my current challenge. I am needing to format specific cells based on the data in a table at the top of the sheet where the row used for comparison changes based on the value in one cell. Here is the link to the sheet I am currently working on.
https://docs.google.com/spreadsheets/d/1t7pgvGjxs1Eb3cCcRnLDA6E9ov5riEDAjn-fX3A0s8I/edit?usp=sharing
-The table at the top of the is the reference table and does not change.
-the number in column E is the data that determines which row of the table to compare the data in columns G through AN
The Situation:
Let's look at Name 3.
The numbers in G18:AN18 are compared to the G12:AN12 because of the matching number in E18 and E12
If the number in G18 equals G12 - no formatting change
If the number in G18 is one less than G12 - fill color Yellow
If the number in G18 is more than one less than G12 - fill color Red
This is true for each cell in row 18 columns G:AN
- That's the easy part -
Now, when the number in E18 changes (from "9" to "10" for example), I need it to stop looking at row 12 and now look at row 13 because E18 now matches E13
I know that I can do it using nested IF/AND statements but I would have to do it for each and every cell individually. How can I do this more easily through google sheets?
You need to use INDEX/MATCH, so for the yellow formatting starting in G16:-
=G16=INDEX($G$4:$R$14,MATCH($E16,$E$4:$E$14,0),COLUMN(A:A))-1
The idea is that as you copy it across the column changes to B:B etc. so you get the next column of the top region and as you copy it down you get whichever row matches E16, E17 etc.
I'm sure you can modify it for the red formatting and also to take account of any blank cells.
Also, in this particular case that the numbers in E4:E14 are just the numbers 1-11, you could use E16:E25 to index directly into G4:R14 and make the formula a lot simpler like this:-
=G16=INDEX($G$4:$R$14,$E16,COLUMN(A:A))-1

Resources