Interior オブジェクト (Excel)

オブジェクトの内部を表します。

Range オブジェクトの Interior プロパティを使用して、Interior オブジェクトを取得します。 次の使用例は、セル A1 の内部の色を赤に設定します。

Worksheets("Sheet1").Range("A1").Interior.ColorIndex = 3

次の使用例は、 ColorIndex プロパティを使用して列 A のセルの色の値を取得し、その値を使用して色で範囲を並べ替えます。

Sub ColorSort()
   'Set up your variables and turn off screen updating.
   Dim iCounter As Integer
   Application.ScreenUpdating = False
   
   'For each cell in column A, go through and place the color index value of the cell in column C.
   For iCounter = 2 To 55
      Cells(iCounter, 3) = _
         Cells(iCounter, 1).Interior.ColorIndex
   Next iCounter
   
   'Sort the rows based on the data in column C
   Range("C1") = "Index"
   Columns("A:C").Sort key1:=Range("C2"), _
      order1:=xlAscending, header:=xlYes
   
   'Clear out the temporary sorting value in column C, and turn screen updating back on.
   Columns(3).ClearContents
   Application.ScreenUpdating = True
End Sub

プロパティ

関連項目

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。