何か他の目的と組み合わせて使うような手順ですが、「入力内容の一番下の行を取得する」方法のご紹介です。
最後の行を取得する
データの個数を数える
CountA(範囲)
CountA(範囲)

こんな表があるとして……。

一番最後(下)の行の内容を取得してみたいと思います。

まずは、行にデータがいくつかあるかを取得します。=counta(B:B)(B列全ての入力されたデータの数を数える)と入力します。

B列には12個のデータが存在することがわかりました。
今回は行すべてで行ってますが、内容に応じて=counta(B2:B1000)のように開始位置・範囲は調節してください。
今回は行すべてで行ってますが、内容に応じて=counta(B2:B1000)のように開始位置・範囲は調節してください。

さて、あとは取得した数字にアルファベットをつけて、=B12とすれば表示されそうなものです。
そこで=”=B” & counta(B:B)(あるいは=”B” & counta(B:B))のように入れてみましたが……。
そこで=”=B” & counta(B:B)(あるいは=”B” & counta(B:B))のように入れてみましたが……。

これだとなんかうまくいきません。

そこで、Indirect関数というのを使ってみます。=indirect(“B” & counta(B:B))と入れてみると……。

なぜかうまくいきました。

試しにデータを追加してみましたが、ちゃんと動作するようです。
Indirect関数とは
指定した文字列を参照する
Indirect(文字列)
Indirect(文字列)

Excelの仕様として、直接=B12とセルに入力するのと、&関数でくっつけた結果=B12となったものでは挙動が異なります。

こんな感じで、参照式ではなくただの文字列として扱われます。
この文字列を「参照して良い」と許可を与えるのがIndirect関数です。
この文字列を「参照して良い」と許可を与えるのがIndirect関数です。

Indirect関数で参照する対象には「=」はいらないので、消します。

「B」と「12」を別々のセルから参照し、これをIndirect関数で参照して、=indirect(G5 & H5)という式を作ります。

するとちゃんと
参照式として機能します。Indirect関数はこういう感じです。
参照式として機能します。Indirect関数はこういう感じです。

Excel(エクセル):抽出、抜き出し
Excelであるデータ内から特定のデータを「抜き出す」「抽出する」操作、のまとめです。
値の抽出
Value関数を使うと、日付や金額などから書式を抜き、標準形式の値だけを抽出することができます。
文字列の抽出
...

関数・演算子・メソッド・プロパティ名から探すExcel/VBA(マクロ)使い方・組み合わせ方まとめ
こちらはExcelやメソッドの諸機能を、機能の名称から探せるまとめ記事です。
コメント