Google Spreadsheet conditional formatting script

后端 未结 4 869
遥遥无期
遥遥无期 2020-12-16 13:22

I am trying to figure out how to use conditional formatting on a google spreadsheet similar to what you can do in excel via a formula.

I want cell A2 to change to Gr

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 13:50

    In the new Google sheets, this no longer requires a script.

    Instead, in conditional formatting, select the option "custom formula", and put in a value like =O2="X" - or indeed any expression that returns a boolean true/false value.

    From what I can tell, the references listed in these custom scripts are a bit weird, and are applied as follows...

    If it's a cell within your selected range, then it is changed to "the cell that's being highlighted".

    If it's a cell outside your selected range, then it's changed to "that position, plus an offset the same as the offset from the current cell to the top left of the selected range".

    That is, if your range was A1:B2, then the above would be the same as setting individual formatting on each cell as follows:

    A1 =O2="X"
    A2 =O3="X"
    B1 =P2="X"
    B2 =P3="X"
    

    You can also specify fixed references, like =$O$2="X" - which will check the specific cell O2 for all cells in your selected range.

提交回复
热议问题