GAS スプレッドシートの指定したセルの範囲からセルを取得する
- 作成日 2022.05.08
- 更新日 2022.05.27
- Google Apps Script
- Google Apps Script
![GAS スプレッドシートの指定したセルの範囲からセルを取得する](https://mebee.info/wp-content/uploads/2022/04/gas-890x500.png)
GAS(Google Apps Script)で、スプレッドシートの指定したセルの範囲からセルを取得する手順を記述してます。
環境
- OS windows11 home
- ブラウザ chrome 100.0.4896.127
セルの範囲からセルを取得
セルの範囲からセルを取得するには、「getCell()」を使用します。
range.getCell()
以下の「シート」から取得してみます。
![](https://mebee.info/wp-content/uploads/2022/05/image-29.png)
コードを実行します。
function myFunction() {
// GASを作成したスプレッドシート
let spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// スプレッドシートのシート名「シート1」を取得
let sheet = spreadsheet.getSheetByName("シート1");
// セルを指定
let range = sheet.getRange("B1:C3");
// セルの範囲から位置を指定
let cell = range.getCell(1, 1);
// 値を取得
Logger.log( cell.getValue() );
}
取得されていることが確認できます。
![](https://mebee.info/wp-content/uploads/2022/05/image-30.png)
-
前の記事
VSCODE matplotlibのグラフを表示する 2022.05.08
-
次の記事
javascript エラー「TypeError: null is not an object (evaluating ‘xxx.value’)」の解決方法 2022.05.09
コメントを書く