0
0

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 3 years have passed since last update.

GASでスプレッドシート名を取得して、セルに設定する

Posted at

やりたいこと

Screenshot from 2021-03-19 21-46-50.png
赤枠の名前をセルに設定したい
エクセルなら
=MID(CELL("filename"),FIND("[",CELL("filename"))+1,FIND("]",CELL("filename"))-FIND("[",CELL("filename"))-1)
見たいな関数で取れるみたいですが、スプレッドシートは上手いことできないので、GASで入力します

GAS


function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var name =  ss.getName();
  var sheet = ss.getSheetByName('summary');
  sheet.getRange(2,1).setValue(name);
};

summaryと言う名前のシートのA2(2,1)セルにスプレッドシート名を設定するスクリプト

実行結果

Screenshot from 2021-03-19 22-03-32.png

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?