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 支持和反馈,获取有关如何接收支持和提供反馈的指南。