Question

I am trying to get a Google spreadsheet to automatically highlight all rows in a spreadsheet where the value in a particular column is above 0. I have looked for a few solutions but haven't got it to work.

I have got various metrics in the columns, so say I want to highlight all rows, in which column "I" has a value of more than zero.

Can someone help me with this?

Was it helpful?

Solution 3

The only solution I'm aware of would be to write a script.

Link: Google Apps Scripts

The following is not pretty, but it works:

function myFunction() {
  var I_INDEX = 1;
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Highlight rows");
  var dataRange = sheet.getDataRange();
  var dataValues = dataRange.getValues();
  for (var i=1; i<=dataRange.getNumRows(); i++) {
    var row = sheet.getRange(i, 1, 1, 2);
    if (dataValues[i-1][I_INDEX] > 0) {
      row.setBackground("red");
    }
  }
}

See example, use "Tools" --> "Script Editor..." to view/run the script.

OTHER TIPS

On the conditional formatting page choose "Custom formula is" from the list of options available and then in the text field type:

=$I:$I>0

Select your formatting options and then in the range field type the range. For example:

A2:Z100

Because only to be applied to a single column there is a simpler version (that I have complicated so that text is not highlighted):

Clear formatting, select ColumnI and Format, Conditional formatting..., Format cells if... Custom formula is and:

=and(isnumber(I1),I1>0)

with fill of choice and Done.

If to format not just the relevant cell but the entire row then change the Apply to Range (say to A1:Z1000) and add anchors ($s) as below:

=and(isnumber($I1),$I1>0)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top