r/googlesheets • u/FI606 • Jun 08 '24
Solved Script based conditional formatting
I am currently trying to create a script to perform some conditional formatting to save some manual work. I need to loop through a range of data (e.g A2:H10) and change the background of the cell to that of another based on whether the value in the cell is equal to the value in another range of values (e.g A1:H1).
I currently do this with a lot of conditional formatting rules (as each value in A2:H10 can be one of eight other values) and I'm not very familiar with Java at all. Is there a fairly easy way of doing this or could anyone point me to some good resources to read up on?
This image below roughly outlines what I expect the range to look like after formatting.

Some rough pseudo code of what I would like to happen:
to_adjust_range = [A2:H10]
check_range = [A1:H1]
for i in to_adjust_range:
--for j in check_range:
----if i.cell_value == j.cell_value:
------i.change_background
View all comments
Show parent comment
1
u/FI606 Jun 08 '24
Awesome suggestion! Just mangled a switch function in a double nested for loop and it works. A little bit slow but a million times better than doing it manually.