8
8

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 5 years have passed since last update.

Googleスプレッドシートで選択範囲内の要素を数え上げ

Last updated at Posted at 2014-10-18

Google Apps Script を用いて、Googleスプレッドシートの選択範囲内の要素を数え上げます。

スクリプト

wordCount.gs
function wordCount(array_array) {
  var result = {};
  for (var i = 0; i < array_array.length; i++) {
    var array = array_array[i];
    for (var j = 0; j < array.length; j++) {
      var word = array[j];
      if (result[word] == undefined) {
        result[word] = 1;
      } else {
        result[word]++;
      }
    }
  }
  var result_array = [];
  for (var word in result) {
    result_array.push([word, result[word]]);
  }
  return result_array;
}

使い方

下記の図のような、広い範囲にある要素を数え上げます。
4.png

関数を利用する際は、=wordCount(範囲)とすると、下記の図のように範囲内の要素が数え上げられます。
5.png

8
8
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
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?