Search code examples
google-apps-scriptgoogle-sheetscolorsformatting

Conditional formatting rule to colour an entire row in google sheets


This is related to a similar question asked here

I am currently managing a live spreadsheet that updates regularly, and uses the "importrange' function. This import range function does not copy over any formula or formatting from the spreadsheets it gets data from, just the contents of the cell.

Currently, I manually change the fill colour for each of the totals rows a specific colour. But when the lists change in length, values will be pushed down rows, but the colouring will remain at the original cells.

I have set up conditional formatting (I applied 'if value is greater than 0' to the B column) to colour the (single) total value in the totals row. But I want the entire row to be coloured. Would there be a way to write conditional formatting rules to colour the entire row?

I have an example of what I want the spreadsheet to look like below. The letter 'a' means that there will be words in the cell, and the number '1' means that there will be numbers in the cell. There will be one 'total' value, and I want the entire row to be coloured if there is a total value.

Image of current spreadsheet layout

Image of the desired outcome

ie. cells B6 and B15 are totals of the number of entries above, that have been coloured based on conditional formatting. I want the conditional formatting to then colour the entire rows 6 and 15 automatically so it looks like the desired outcome.

I am interested to learn about how the specific conditional rules if anyone is willing to explain/link something. Otherwise, just the rule is fine.


Solution

  • There are several videos and documentation about this, you can start from Google's one

    For colouring cells depending on others, it will always need the option Custom Formula - you have to select the whole range, look for that option, and inside it you have to write the function as if it were written for the first cell in the range and you'd like to copy and paste it to the whole range. In this case:

    =$B2>0
    

    Since the B is anchored it will always check the value in B from each row