Share via


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 支援與意見反應