Google Spreadsheet Hide and unhide rows based on cell values

谁都会走 提交于 2021-01-29 15:24:01

问题


I have a spreadsheet with date's (Months) I'm looking for a script that hides and unhide's rows automatically.

In column "Z" is a formula (=IF(A3=TODAY();"";"1")) So the cells containing "1" has to hide the row and the empty cells should unhide the row.

Can anyone help me? I have seen a lot of forums with no result for me :(

See the example below!

Example


回答1:


function hideShow() {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getActiveSheet();
  var rg=sh.getRange(3,26,sh.getLastRow()-2,1);
  var vA=rg.getValues();
  for(var i=0;i<vA.length;i++) {
    if(vA[i][0]==1) {
      sh.hideRows(i+3);
    }
    if(vA[i][0]==0) {
      sh.showRows(i+3);
    }
  }
}


来源:https://stackoverflow.com/questions/58084833/google-spreadsheet-hide-and-unhide-rows-based-on-cell-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!