Google Sheets - Conditional Formatting based on value of cell in another sheet - Custom Formula - if-statement

How can I achieve the following:
Sheet1: has a range of cells A1:M13 which have conditional format rules: if text is exactly "1" (to "15" so 15 rules) → each number gives the cell a different background filling.
Sheet2: I want do Conditional Formatting on range A1:M13 based on the cell values in Sheet1!A1:M13.
At the moment I have the following custom formula in conditional formatting:
=if((INDIRECT("Sheet1!A1:M13=1")))
What do I do wrong? Do I have to set format of Sheet1 to value=1 instead of text is exactly "1"?

Apply this to range A1:M13 in Sheet2 for cell to cell comparison:
=1=INDIRECT("Sheet1!"&CELL("address",A1))

try:
=INDIRECT("Sheet1!"&A1)=1
or
=INDIRECT("Sheet1!"&A1)="1"

Related

Google Sheet Conditional Formatting highlight 2 columns if one column contain certain text of 5 columns

In Google Sheet, I want to highlight only 2 columns out of 5 columns.
5 columns here but I want to highlight only 'Name' and 'Weight' columns if a cell contain the word 'Smith'
The outcome should be like this.
I want to input more name and if the name contain the word 'Smith', I want it to be automatically highlighted for name and weight columns.
I tried to use conditional formatting in Google sheet, and I could highlight only the name column.
This is what I tried.
Outcome was this.
You are not far, try the following formula in the conditional formatting:
=IF(REGEXMATCH($C3, "Smith"), 1, 0)
The formula given by #nabais works.
In conditional formatting though one does not need to use the starting IF function.
"Format cells if" is how conditional formatting rules are formed by default as noted in the official help page.
Create a rule.
Single color: Under "Format cells if," choose the condition that you want to trigger the rule. Under "Formatting style, choose what the
cell will look like when conditions are met.
Color scale: Under "Preview," select the color scale. Then, choose a minimum and maximum value, and an optional midpoint value. To choose
the value category, click the Down arrow Down Arrow.
So the following formula is all that is needed:
(Please adjust ranges to your needs)
=REGEXMATCH($G2, "Smith")
You can try the following code:
function highlight() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var data = ss.getRange('A1:E').getValues();
for (i = 1; i < data.length; i++) {
var tf = ss.getRange("B" + i).createTextFinder('smith');
tf.matchEntireCell(false);
tf.matchCase(false);
var result = tf.findNext();
if (result !== null) {
var range = result.getRow();
ss.getRange('B' + range).setBackground('Yellow');
ss.getRange('D' + range).setBackground('Yellow');
}
};
};

Conditional formatting: IF contains XX OR YY OR ZZ

So im making a spreadsheet for fun but I need some help because it would be generous to say my experience is amateur level.
I want to change the color of the cell to the same color if they contain one of a range of different values (all string text)
Example: If cell contains "XXX" or "YYY" or "ZZZ" then colorchange =true, else color = white
I don't really want to have to make separate rules for each string because theres about 80 of them in total
use custom formula:
=REGEXMATCH(A1, "XXX|YYY|ZZZ")
note its case sensitive so to turn off the sensitivity do:
=REGEXMATCH(UPPER(A1), "XXX|YYY|ZZZ")
you can also put your 80 values in a column and use:
=REGEXMATCH(A1, TEXTJOIN("|", 1, Z:Z))
where Z:Z contains all your values
if you want to put those values on a different sheet use:
=REGEXMATCH(A1, TEXTJOIN("|", 1, INDIRECT("Sheet2!Z:Z")))

Highlighting a whole row if number of blank cells in the row = a certain number

I'm trying to highlight a row if the number of blank cells between say, C1 and E1 = 3
and then copy this down for every row.
I've tried using:
=IF(COUNTBLANK($C1:$E1)=3)
But it's not working, can anybody help?
Under conditional formatting, your formula should be the following based on what you've given. The reason is conditional format is trying to see the result as TRUE or False. The IF statement is trying to tell the computer what to do when it's TRUE or FALSE.
COUNTBLANK($C1:$E1)=3
if you want to use IF you will need to do it like this:
=IF(COUNTBLANK($C1:$E1)=3, 1)

How to count the number of blank cells in one column based on the first blank row in another column

I have a spreadsheet set up with tv program titles in column B, the next 20 or so columns are tracking different information about that title. I need to count the number of blank cells in column R relating to the range in column B that contains titles (ie, up to the first blank row in column B.)
I can easily set up a formula to count the number of empty cells in a given range in column R, the problem is as I add more titles to the sheet I would have to keep updating the range in the formula [a simple =COUNTIF(R3:R1108, "")]. I've done a little googling of the problem but haven't quite found anything that fits the situation. I thought I would be able to get the following to work but I didn't fully understand what was going on with them and they weren't giving the expected results.
I've tried these formulas:
=ArrayFormula(sum(MIN("B3:B"&MIN(IF((R3:R)>"",ROW(B3:B)-1)))))
=ArrayFormula(sum(INDIRECT("B3:B"&MIN(IF((R3:R)>"",ROW(B3:B)-1)))))
And
=if(SUM(B3:B)="","",SUM(R3:R))
All of the above formulas give "0" as the result. Based on the COUNTIF formula I have set up it should be 840, which is a number I would expect. Currently, there are 1106 rows containing data and 840 is a reasonable number to expect in this situation.
Is this what you're looking for?
=COUNTBLANK(INDIRECT(CONCATENATE("R",3,":R",(3+COUNTA(B3:B)))))
This counts the number of non-blank rows in the B column (starting at B3), and uses that to determine the rows to perform COUNTBLANK in, in column R (starting at R3). CONCATENATE is a way to give it a range by adding strings together, and the INDIRECT allows for the range reference to be a string.
a proper way would be:
=ARRAYFORMULA(COUNTBLANK(INDIRECT(ADDRESS(3, 18, 4)&":"&
ADDRESS(MAX(IF(B3:B<>"", ROW(B3:B), )), 18, 4)))
or shorter:
=ARRAYFORMULA(COUNTBLANK(INDIRECT("R3:"&
ADDRESS(MAX(IF(B3:B<>"", ROW(B3:B), )), 18, 4))))
or shorter:
=ARRAYFORMULA(COUNTBLANK(INDIRECT("R3:R"&MAX(IF(B3:B<>"", ROW(B3:B), ))))

Change cell background color based on text in another column

What would the syntax be to conditionally format - if any cell in Column A contains a value that matches any value in Column B then display a blue background?
Looks like this would be done using Conditional Formatting under Format, where this custom formula works.
=OR(A1:A1000="Text Sample 1",A1:A1000="Text Sample 2")
Instead of listing a bunch of values in this formula, is there syntax that can represent values listed in another column (Column B)?
use this custom formula:
=REGEXMATCH(A1, TEXTJOIN("|", 1, B$1:B))
for exact finds use:
=REGEXMATCH(A1, "^"&TEXTJOIN("$|^", 1, B$1:B)&"$")
Custom Formula:
=QUERY(B:B," Select count(B) where B is not null and '"&A1&"' contains B label count(B) ''",0)
Apply to:
A1:A
Queries Column B for every cell in A starting from A1 and outputs count of cells.