Excel

セルの背景色の設定


セルの背景色を設定するには、RangeオブジェクトのInteriorプロパティのColorIndexプロパティの値を変更します。

例えば、A1セルの背景色を黄色にしたい場合は、次のように記述します。

Range("A1").Interior.ColorIndex = 6

行全体の背景色を変更したい場合は、Rowsオブジェクトを利用します。

Rows(1).Interior.ColorIndex = 6

ちなみに、特定のセルを含む行全体を取得するには、EntireRowプロパティを利用すると便利です。

Range("A1").EntireRow.Interior.ColorIndex = 6