Excelについて(関数、VBA)

Excelについてのメモ、参考ページ。
VBA、関数とかいろいろわかっていなかったので今勉強中。備忘録。

・チップ集
VBA - アプリケーションとしてのVBA
http://www.k1simplify.com/index.html#tips_menu01


Excelマクロのための色番号表 number of colorIndex
http://www.ne.jp/asahi/mabu-messages/greetings-2-you/colorIndexnum.htm
色分けされた部分の抽出に便利。

・Functionプロシージャ
http://www.asahi-net.or.jp/~ef2o-inue/vba_k/sub04_110_02.html
関数作ってマクロに埋め込む or 標準の関数みたいに使えるように準備しておこう。

VBAの関数
http://officetanaka.net/excel/vba/function/
ここでとりあえず調べればなんとか目的のもの見つかりそう。

Cellsプロパティ ・ Offsetプロパティ
http://kabu-macro.com/vba_apply/cells-offset.html
Offsetで別場所の情報にアクセスしていろいろできそう。

Sub テスト2()
Dim 行 As Long, 個数 As Long, 色 As Long, 科目 As Long
個数 = 0
科目 = Range("L2").Value - 1
For 行 = 2 To 100
色 = Cells(行, "G").Interior.ColorIndex
If 色 = 3 Then
個数 = 個数 + 1
End If
行 = 行 + 科目
Next 行
ActiveCell.Value = 個数
End Sub

少し書いてみる。
一定の列数ごとに背景赤色の部分を数えてアクティブセルに入れるサンプル。