32
31

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.

SpreadSheet にてシートの最終更新日時を自動挿入する GoogleAppScript

Last updated at Posted at 2015-12-29

下記のようにシート毎の最終更新日時がA1セルに自動的に挿入されるようになります。

image

やり方

  1. 挿入したいスプレッドシートのメニューから AppScriptの編集画面を開く
    image
     

  2. 下記AppScriptを設定する

    Code.gs
    function insertLastUpdated() {
      SpreadsheetApp.getActiveSheet()
        .getRange('A1') //挿入したいセル
        .setValue(
          '最終更新: ' + Utilities.formatDate(new Date(), 'JST', 'yyyy年MM月dd日HH時mm分ss秒') + //日時フォーマット
          ' by ' + Session.getActiveUser().getEmail() //更新したユーザーアカウント
        )
        .setFontColor('red'); //文字色
    }
    

3. スプレッドシートのトリガーを設定する
![image](https://qiita-image-store.s3.amazonaws.com/0/15751/f8bf440f-b702-e72e-ed12-26bd86ca4098.png) 
 
![image](https://qiita-image-store.s3.amazonaws.com/0/15751/c95d93f9-67b7-3ca2-0983-5958876d153b.png)
32
31
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
32
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?