ご訪問ありがとうございます。
Googleシートマスターのひろしです。
前回

【GAS基礎講座 4. 】セルの値や属性をサクッと削除(clearFormat)
GAS基礎講座一覧
ご訪問ありがとうございます。
Googleシートマスターのひろしです。
前回
今回は、とっても価値の高い方法をお伝えします。
これを知ることであなたは、
GAS(Goo...
今回は、とっても価値の高い方法をお伝えします。
これを知ることであなたは、
- GASでテキストの検索方法がわかります。
- 一つのセルで1年分の日付を表示させることができます。
なので、サクッとマスターして
と答えてあげてください。
動画はこちら
【GAS】Googleスプレッドシートワンクリックで今日の日付に移動する方法
スクリプトはこちら
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//今日の日付に移動する function MoveTodayCell() { const DATEFORMAT = 'yyyy年M月d日' //検索する日付のフォーマット const sh = SpreadsheetApp.getActive() const todayStr = Utilities.formatDate(new Date(), 'JST', DATEFORMAT) // console.log(todayStr) const textFinder = sh.createTextFinder(todayStr) const cells = textFinder.findAll(); // console.log('ヒット数 : ' + cells.length) // for (i = 0; i < cells.length; i++) { // console.log('セル位置 : ' + cells[i].getA1Notation()) // } sh.getRange(cells[cells.length - 1].getA1Notation()).activate() } |
ポイント
文字の検索
createTextFinderで取得した検索結果は、配列なので
アクセスする際には、添字を指定する必要があります。
例)
const textFinder = sh.createTextFinder(todayStr)
const cells = textFinder.findAll();
cells[0].getA1Notation() //一番最初に見つかったセルの位置
cells[cells.length – 1].getA1Notation() //一番最後に見つかったセルの位置
今日の日付
Utilities.formatDate(new Date(), ‘JST’, ‘yyyy/mm/dd’)
一年分の日付を表示させる数式
1 |
=ArrayFormula(date(2022,1,1)+SEQUENCE(365,1,0)) |
最後までご覧いただきありがとうございます。
つぎはこちら

【GAS30】指定した文字列をすべて置換する方法 replace
ご訪問ありがとうございます。
Googleシートマスターのひろしです。
前回の動画
関連動画→「【初心者向け】Googleフォームでいきなり返信メールを送れるようになる方法」
今回は、とっても価値の高...
コメント