2012-08-21

Excel VBA- Set Field Color

ColorIndex 用來設定 Excel 欄位的背景顏色
設定方式


Cells(1, 1).Interior.ColorIndex = 1




顯示顏色索引


Public Sub ShowColorIndex()
    Dim ColorIndex As Long
    Dim i As Long
    Cells(1, 1).Value2 = "Index"
    Cells(1, 2).Value2 = "Color"
    i = 2
    For ColorIndex = 1 To 56
        Cells(i, 1).Value2 = ColorIndex
        Cells(i, 2).Interior.ColorIndex = ColorIndex
        i = i + 1
    Next
End Sub

沒有留言:

adsense