1
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.

google spreadsheetの一番下の値(最新の値)を別シートに記載する

Last updated at Posted at 2021-07-05

Google SpreadSheetにGoogle Apps Scriptを使って5分おきとか1分おきに記録しているデータのうち、一番新しいデータを取得するための関数について説明します。

Google SpreadSheetにデータがたくさんたまってくるとグラフが見づらくなってしまったので、Google Data Portalへ移植しました。Google Data Portalのスコアカードに最新値を出力したかったのですが、スコアカードには平均とか合計とかしか表示できなかったので、1個のデータしか入っていないようにして合計値=最新値にしました。

やり方1

最後のデータ.png

  • 別のシートを作成し、indirect関数でセルを指定する
    • データが保存されているシートは"test1"というシート名です
    • counta(test1!A:A) にて↑の絵でいうところの、19289が出力されます
    • ↓の関数だと、B19289 セルの値が参照されるので、"65" という値が入力されます
=indirect("test1!B"&counta(test1!A:A))

やり方2

最後のデータ2.png

  • 力技です
    • A列の行数を求めていますcounta(test1!A:A)) (↑の絵でいうところの140093)
    • B140093 が空っぽならB140092の値、さらに空っぽだったらB140091の値という書き方をしています
=if(indirect("test1!B"&counta(test1!A:A))="",if(indirect("test1!B"&counta(test1!A:A)-1)="",if(indirect("test1!B"&counta(test1!A:A)-2)="",if(indirect("test1!B"&counta(test1!A:A)-3)="","no data",indirect("test1!B"&counta(test1!A:A)-3)),indirect("test1!B"&counta(test1!A:A)-2)),indirect("test1!B"&counta(test1!A:A)-1)),indirect("test1!B"&counta(test1!A:A)))
1
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
1
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?