11

I'd like to apply a conditional formatting rule to a named range. Is that even possible? How do I do that? When trying to enter the Name of the Range to the Field where you set up the range the rule applies to it won't accept my input.

Also with INDIRECT it does not work:

enter image description here

player0
  • 124,011
  • 12
  • 67
  • 124
haemse
  • 3,971
  • 5
  • 28
  • 40

4 Answers4

9

enter image description here

this is not possible in Google Sheets


for the custom formula you need to wrap it into INDIRECT formula like:

0

player0
  • 124,011
  • 12
  • 67
  • 124
1

I think it is not possible, it is not documented in official docs.

Range names:

  • Can contain only letters, numbers, and underscores.
  • Can't start with a number, or the words "true" or "false."
  • Can't contain any spaces or punctuation.
  • Must be 1–250 characters.
  • Can't be in either A1 or R1C1 syntax. For example, you might get an error if you give your range a name like "A1:B2" or "R1C1:R2C2."
PEZO
  • 441
  • 4
  • 14
1

The following works for my specific use case, where the named range is an "unknown" number of rows.

In this case, A1 is a column heading, and is not part of the named range. A2:A5 is currently assigned to the named range, CitationType. Conditional formatting is applied to A1:A based on the formula:

=and(row(A1)>1,row(A1)<=1+rows(indirect("CitationType")))

I did not find an easy way (without scripting) to get the address details of a named range, allowing for "arbitrary" usage in conditional formatting.

AStephens
  • 11
  • 2
0

For custom formulas in Sheets conditional formatting, the formula usually accesses a column value in the first row of the format range. Named range values can be used in custom formulas using INDIRECT function.

example from my case ... a list of "brackets" in a tournament. Bracket rows are coloured depending on what bracket the row is for (e.g. brackets 1-10), that value is in the E column.

The formula specifies the appropriate column in the first row of the range (row is relative as conditional formatting iterates over the range). Since my range is B2:G1005, the formula references cell $E2 (the bracket ID) and compares it to the bracket id stored in a named-range location (BID_1), so custom formula is:

=$E2=INDIRECT("BID_1")

(if bracket matches the ID assigned to bracket 1 -- colour the cells grey with bolded black text).

Screenshot of conditional formatting using a named range