Questions tagged [google-sheets-conditionalformatting]

Use for questions about conditionally changing the formatting of ranges in Google Sheets spreadsheets, either programmatically via Google Apps Script or via UI inasmuch as the question is about using formulas as conditions.

About

Conditional formatting is a technique used to format text or background color of ranges when they match certain criteria. In the context of Google Sheets, it can be achieved either by using Google Apps Script or providing a custom formula as a condition in the UI.

Use for questions

About programmatic creation and management of conditional formatting rules in either via or custom formulas. For latter use with tag.

Do not use for questions

About conditional formatting in Excel, use + instead.


via custom formulas

Custom formulas for conditional formatting are added via the "Add new rule" > "Custom formula is" menu by selecting a "Value or formula" option.

Custom formulas in conditional formatting are limited to the sheet they are applied to. If you need to reference another sheet, use =INDIRECT formula.


via Google Apps Script

SpreadsheetApp service offers several methods for programmatically creating and managing conditional formatting rules:

a set of utility classes for building rules and conditions:

and several enums for condition options:


Useful resources

  1. Support portal guide
8 questions
10
votes
2 answers

Conditional formatting in Google Sheets: Can I use custom function in the 'custom formula is:' field?

While applying conditional formatting in Google spreadsheet, I was wondering if it's possible to use a custom function that I created via script editor in the field 'custom formula is:'. Here is what I did: Went to 'script editor' and typed my fn…
5
votes
2 answers

How to programmatically delete all conditional formatting on a Google Sheet?

I tried combining two examples from https://developers.google.com/sheets/api/samples/conditional-formatting Read all conditional formats. Delete them. Deletion requires the index to delete, but this is not returned in the read API response. I…
2
votes
2 answers

How to copy conditional formatting between different spreadsheets in Google Apps Script

I have multiple spreadsheets titled: Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. Each spreadsheet has 3 sheets titled: Plan, Class, and Coach. Each spreadsheet has near-identical formatting, the only difference being the height of…
2
votes
2 answers

How to use a script to copy conditional formatting rules from one sheet to another?

I'm trying to copy conditional formatting rules from one of my sheets to others, in Google Sheets. I know, I can just copy and use "paste special" to copy/paste them in, but I specifically want to use a script, because I've set up a script that…
1
vote
1 answer

Google Sheets script, maintaining conditional formatting after inserting a row

I have a spreadsheet, where I have a list of items from row 6 down. the fifth row is reserved for inputting new item details. Then I use a custom button to add the item to the list (insert new row above row 6, copy row 5 to row 6, clear row 5). My…
1
vote
2 answers

Compare the values in two Google worksheets in the same document

I have a Google spreadsheet which contains two worksheets. Each sheet contains a column of URLs followed by 6 columns of data. I would like to highlight on the second sheet if the value is different, ideally styling the particular cell with a red or…
0
votes
1 answer

How to protect conditional formatting in google sheet?

I have 2 CFs in a sheet that I would like to keep upon copy/pastes you can see the range and formulas below. CF1 Range : B3:H1001 CF1 Formula : =($A3<>"")*(B3="") //This one higlights the empty cells in a given range CF2 Range : A3:R1001 // This…
-4
votes
2 answers

How to use VBA in Google Sheets to highlight cells with special characters and uppercase letters?

I managed to get a VBA-snippet working in Microsoft Excel that highlights all Cells in Range C1 to E10000 which contain anything else than lowercase a–z, numbers and hyphens. The code looks like this: Option Explicit Sub SpecialChars() Dim…