Google Sheets – Dynamically Format Diagonal Cells

google sheetsgoogle-apps-script

I want all of the diagonal cells (A1, B2, C3, D4, E5, etc) of a Sheet to be formatted as Black Background, White Foreground. Is there any way to do this for a Sheet that constantly increases in size?

If I manually do so for the first 50 diagonal cells and the Sheet increases in size, the 51st diagonal cell will not share the same formatting. I'll have to go back and format it myself again.

Is there an easy way to go about this?

Best Answer

Automatic if within the existing formatted range (ie added rows are above and added columns are to the left) would be conditional formatting with Custom formula is

=row()=column()  

and Text Colour: white (assuming this is what you mean by foreground) and Background Colour: black applied to Range: to suit.