以下改自于别人的代码,供参考:
For myColors = 1 To 56
Cells(myColors, 1).Interior.ColorIndex = myColors
Cells(myColors, 2) = myColors
Cells(myColors, 6) = Cells(myColors, 1).Interior.Color
HexString = Right("000000" & Hex(Cells(myColors, 1).Interior.Color), 6)
HTMLcolor = "#" & Right(HexString, 2) & Mid(HexString, 3, 2) & Left(HexString, 2)
Cells(myColors, 3) = HTMLcolor
RGBColor = Cells(myColors, 1).Interior.Color Mod 256
RGBColor = RGBColor & " " & Int(Cells(myColors, 1).Interior.Color / 256) Mod 256
RGBColor = RGBColor & " " & Int(Cells(myColors, 1).Interior.Color / 256 / 256)
Cells(myColors, 4) = RGBColor
ColName = Array("Black", "White", "Red", "Bright Green", "Blue", "Yellow", "Pink", "Turquoise", _
"Dark Red", "Green", "Dark Blue", "Dark Yellow", "Violet", "Teal", "Gray-25%", "Gray-50%", "Periwinkle", _
"Plum", "Ivory", "Light Turquoise", "Dark Purple", "Coral", "Ocean Blue", "Ice Blue", "Dark Blue", "Pink", _
"Yellow", "Turquoise", "Violet", "Dark Red", "Teal", "Blue", "Sky Blue", "Light Turquoise", "Light Green", _
"Light Yellow", "Pale Blue", "Rose", "Lavender", "Tan", "Light Blue", "Aqua", "Lime", "Gold", "Light Orange", _
"Orange", "Blue-Gray", "Gray-40%", "Dark Teal", "Sea Green", "Dark Green", "Olive Green", "Brown", _
"Plum", "Indigo", "Gray-80%")
COLORNAME = ColName(myColors - 1)
Cells(myColors, 5) = COLORNAME
Next |