Conditional Formatting Based On Another Column Data - google-apps-script

I want to use color scale while doing conditional formatting in a column, based on the color scale used on another column. For example, if in A Column I am having names of students and in B column I am having their scores. I have done condition formatting using color scale in B column like lowest will be red and highest will be white and other shades of red for the scores in between. I want the column with names to have the same formatting as the scores. Kindly help

This can be done by replicating the formulas for your conditional formatting in Column B to also be reflective in column A.
If for example you have the value of 25 in column B and what to give this a red text colour. You would create a conditional formating rule that has the following settings
Apply to Range - B:B
Format Rules - Text Contains - 25
Formatting style - red text
You can then apply this format to column A with the following settings for a conditional formatting rule in column A
Apply to Range - A2:A10 (extend to the range you need)
Format Rules - Custom Formula is - =$B2=25
Formatting style - red text
If you then enter 25 into column B it should also format column A. You would then need to replicate this for every conditional format rule that you have

Related

Change the color of column A, if values match in 3 other columns

I'm looking to change the color of the cell in column A for a row that matches 3 different values across the column. Using Google Sheets, I have tried conditional formatting but can't figure it out.
Example: if column C is today's date, and if column G is also today's date, and if column M has the text "test" in it, then the cell in row A gets pink.
Conditional formatting will work, but I can't figure out how to add multiple required pieces to look for. I tried recording macros too but I'm new at this.
You can add the following custom formula and apply the conditional formatting to column A
=AND($C1=TODAY(),$G1=TODAY(),$M1="test")
I created this test sheet to demonstrate:
https://docs.google.com/spreadsheets/d/1ZJXdINEzy4Gh-OOIpxpiEZSrVtaS-GnFqMbw0FKcxNE/edit?usp=sharing

Sheets lookup on conditional highlight colour

Is it possible to check a cell's conditional highlight colour and act accordingly?
I have a list of Names where some people belong to the "Yellow" team and some the "Pink" team. The Yellow team get more points allocated depending on their level (Cell B3).
Referring to the screenshots attached, I can't work out how to direct the lookup to the appropriate column of points per level in 'Sheet2' relative to the chosen Name. Conditional highlighting (see screenshot) sets the cell colour according to the Name input into cell B2.
Cell B6 contains the following formula:
=vlookup(B3,Sheet2!A1:E11,match(B2,Sheet2!A1:E1,0),)
The formula worked when the reference table had Column B named as "Bob" but that is not what I want.
I want the B6 formula to realize which colour team the B2 Name is and pick from the appropriate data set in 'Sheet2'.
Any help appreciated if it is at all possible to lookup against cell highlight conditions.
Thanks!
There's no direct way of doing it. You might want to use the getBackground() function in Google apps script, but I don't think it's worth using scripts for this case. That would mean making the thing more complicated and less maintainable.
The easiest way you can achieve it is by using a helper cell.
You'll need the two teams listed in two columns. I'll assume to make things simple to have the two ranges E2:E30 for yellow names and F2:F30 for pink names
Add Color in cell A4 and the following formula in B4:
=IF(ISERROR(MATCH(B2,E2:E30,0)),IF(ISERROR(MATCH(B2,F2:F30,0)),"No color","Pink"),"Yellow")
You could then use the result of cell B4 for the VLOOKUP in cell B6.
The added advantage is that you wouldn't need that many conditional formatting rules: you can simply compare the color in B4 and assign a conditional formatting rule accordingly in B2. It's way more maintainable and less error-prone.
Using Named Ranges for conditional formatting (no script, no helper cell)
Since Francesco's excellent proposition on using formulas instead of a script is your choice, you could also try the following.
Turn your team ranges to Named Ranges (by going to Data>>Named Ranges from the top menu) and name them e.g. yellow and PINK
Apply conditional formatting to your data validated cells (B3:E3) by using these two formulas (under Custom formula is found at the end of Conditional formatting rules):
=REGEXMATCH(B3,""&JOIN("|",FILTER(INDIRECT("yellow"),INDIRECT("yellow")<>""))&"")
and
=REGEXMATCH(B3,""&JOIN("|",FILTER(INDIRECT("PINK"),INDIRECT("PINK")<>""))&"")
(Make sure you adjust your ranges according to your data)
Advantages:
It is your original cells that get color coded.
Named Ranges can be placed anywhere, on any tab and can grow to your needs.
You do not need the extra helper cell.
Make a note:
We must use INDIRECT when using named ranges with conditional formatting for the function to work.
We must also surround the named range with double quotes "". So, to refer to the named range yellow we use INDIRECT("yellow).

Conditional formating based on adjacent cell using script

I have a spreadsheet that looks like (but much larger):
Both the student names and the house assignments are pulled from other sheets.
I am looking for a google script that would conditionally format a student name based on the house they are assigned to. The house assignment will always be listed in the cell to the right of the name.
I realize this can be done with conditional formating (For instance: Custom formula =B3:B4="6-Blue"), but it becomes an arduous process because I have to go into each vertical range individually to make a change if the house name changes. With a google script, I could find and replace all instances of a house name.
Something like Eric Koleda's answer may work, but I am unsure how to reference the ranges and add multiple values to search for.
You can still do this with conditional formatting!
You can set up conditional formatting on a per column basis, you don't have to change the formatting, only the name of the color in your house column.
Conditional formatting formula: =ISNUMBER(FIND("Red", $C4))
Conditional formatting range: B4:C
This will try and find the text Red within all cells in Column C starting at C4. If Red is found in a cell, FIND() will return the index of Red, if it doe snot find Red is returns an error. You can check this with ISNUMBER(), which returns true or false if the value is a number or not.
This will color the adjacent columns on that row within the range. ie. A range of B4:C will color the cells in column C and B, a range of just B4:B will only cause the cells in column B to be colored.
You only need to setup one conditional formatting per color, per set of columns that you have. After that, just changing the colors under your houses will change the formatting.
Here is an example sheet I made for you: Example Google Sheet
Picture of Sheet with formatting:

SSRS Tablix Conditional formatting by row number

how can i use conditional formatting a particular row in the tablix object. Example table is 2 columns wide and has 7 rows showing salaries and names for 6 people. How can i format the 6th row?
You have not mentioned what you would like to format in the 6th row,
but to apply different settings/expression on certain row numbers in a table you could use the RowNumber function. For example, for the background color on your table row, you can apply something like the following expresssion:
=IIF(RowNumber("YOUR_GROUPING") = 6, "White", "PaleGreen")
This should set, the color only on the 6th row to white.
More information visit:
http://msdn.microsoft.com/en-us/library/dd255249.aspx

How to change the color of one cell based on the value of another

In fact I have a column called status (K) which contains two values Y or N.
I want to change the background color of another column (J) based on the info from column K.
I want the script to change the color of J to red when K is Y and transparent when K equals N.
I have tried different scenarios on the forum but since I have no notion of java I'm totally blocked.
I need your help please.
Thanks in advance
You might try to use special formatting rules for that but they only apply to the current cell. Thus, you can create a formula to set specific values in column J depending on values on column K and then apply conditional formatting to cells in column J. But of course, this is no different from applying the same to values in column K.
Above I assumed your J column is empty, used only for colors. If you also have data, then you need to update the formula to mix the two.