Using a script to hide columns based on date values

18 views Asked by At

I have essentially no script experience so hopefully I can get some help. I have a sheet with columns grouped under a merged cell with a date, 6 columns per date. I'd like the columns to hide automatically when it's 7 days past the date in the merged cell. Screenshot(https://i.stack.imgur.com/mwTUL.png)

I've tried to record a macro so I could just hit a button and hide the next 6 columns but it only runs on the 6 columns that I select while recording the macro so that won't work.

function HideColumns2() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('H:M').activate();
  spreadsheet.getActiveSheet().hideColumns(spreadsheet.getActiveRange().getColumn(), spreadsheet.getActiveRange().getNumColumns());
  spreadsheet.getRange('N:N').activate();
};
0

There are 0 answers