9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Googleスプレッドシートで、昨日までの日付列を毎朝自動で非表示にするスクリプト

Last updated at Posted at 2013-08-08

業務でGoogleスプレッドシートをガントチャート的に使っていて、もう過ぎた日付の列を毎回手作業で非表示にするのがだるかったのでスクリプト書いた。

hide
function hide() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("hogehoge");
  var column = 4;
  var today = new Date();
  while (column <= ss.getLastColumn()){
    if(sheet.getRange(2, column).getValue() < (today.getTime()-(60*60*24*1000))){
      var range = sheet.getRange(1, column);
      sheet.hideColumn(range);
    }
    column++;
  }
}

トリガーを毎朝5時に仕掛けたので、朝スプレッドシートを開くと昨日までの列は非表示になっている。快適。

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?