AppScript to Hide Rows

Viewed 64

I’ve been trying to make the below script work but at the minute it’s hiding all my rows, instead of just the ones that have a value in column U between 30 and 100.

function ReadinghideRows() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = ss.getSheetByName('Reading');
  var r = s.getRange('U:U');
  var v = r.getValues();
  for(var i=v.length-1;i>=0;i--)
    if(v[0,i]>'30'<'100')
      s.hideRows(i+1);
};

Are you able to help?

Thank you!

This is the updated version but unfortunately it isn't working (I done something wrong on the code)

function ReadinghideRows() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = ss.getSheetByName('Reading');
  var r = s.getRange('U:U');
  var v = r.getValues();
  for(var i=v.length-1;i>=0;i--)
    if 30 < v[0, i] && v[0, i] < 100)
      s.hideRows(i+1);
};

Found the error.... just a missing ( , it should have been like this:

function ReadinghideRows() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = ss.getSheetByName('Reading');
  var r = s.getRange('U:U');
  var v = r.getValues();
  for(var i=v.length-1;i>=0;i--)
    if (30 < v[0, i] && v[0, i] < 100)
      s.hideRows(i+1);
};

Thank you all!

1 Answers
Related