Google Apps Script 指定したシートをアクティブにする方法

環境
Google Chrome 111.0.5563.66(Official Build) (64 ビット)
Windows 10 Home 64bit
Google スプレッドシート

書式
setActiveSheet()
「setActiveSheet」を使用して指定したシートをアクティブにします。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function myFunction() {
// スプレッドシート
let spsheet = SpreadsheetApp.getActiveSpreadsheet();
// 1番目のシートをアクティブにする
spsheet.setActiveSheet(spsheet.getSheets()[0]);
}
function myFunction() { // スプレッドシート let spsheet = SpreadsheetApp.getActiveSpreadsheet(); // 1番目のシートをアクティブにする spsheet.setActiveSheet(spsheet.getSheets()[0]); }
function myFunction() {
  // スプレッドシート
  let spsheet = SpreadsheetApp.getActiveSpreadsheet();

  // 1番目のシートをアクティブにする
  spsheet.setActiveSheet(spsheet.getSheets()[0]);

}

実行結果
「実行」ボタンを押すと、1番目のシートをアクティブにします。

Google Apps Script

Posted by arkgame