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.

GoogleAppsScript スプレッドシートの名前付き範囲から値を取得する

Posted at

スプレッドシートの名前付き範囲から値を取得する

スプレッドシートに設定を記述し、何らかの処理をする場合、名前付き範囲が便利です。

スプレッドシートの名前付き範囲から値を取得する方法を書きます。

例えば↓のようなスプレッドシート
A1~B6に 料理の味 と名前付き範囲を設定したと仮定します。

image.png

ポイント
1 まずスプレッドシートを取得→名前付き範囲の取得と進みます。エクセルのようにシート名の指定はいりません。
2 戻り値は二次元配列です。2次元配列とわかれば取り出し方は簡単!!indexOfで検索したりもできます。

スプレッドシートの名前付き範囲の値取得

  var sheet = SpreadsheetApp.openById('シートのID');
  var cook = sheet.getRangeByName('料理の味').getValues();
  Logger.log(cook[0][0]); //料理の味
  Logger.log(cook[0][1]);  //
  Logger.log(cook[1][0]);  //とてもおいしい
  Logger.log(cook[1][1]);  //5.0

設定の記述に名前付き範囲は便利ですよね。

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?