以下のようにフィルター(thatなど)を利用すればより簡単に最終行を取得できる.
準備
以下のようにcellに値を入れた表を準備する.
フィルターを利用して最終行を取得する.
every
: applescritpではeveryを使うとすべてのitemをリスト(配列)の形で取得できる.that
: さらにフィルター(thatなど)を使うと条件を満たすもののみ抽出できる.この場合,値が入っている(is not missing value)のセルを選んでいる.last
: リストの最後のitemを取り出せる.最初のitemはfirstで取り出せる.
tell column "A" set theList to name of every cell that value is not missing value last item of theList end tell -- 結果"A10"
行に対しても同様の方法で可能.
tell row "2" set theList to name of every cell that value is not missing value last item of theList end tell
last
の箇所をfirst
にすれば,最初行(値がはいっているセルで最も行番号が若いセルの行)の取得もできる.
(http://tonbi.jp/AppleScript/Introduction/07/ 鳶嶋工房 / AppleScript / 入門 / インテリジェントでいこう)