本帖最后由 佛山小老鼠 于 2012-10-1 16:25 编辑
56种颜色和数字值对照表
一些刚学VBA的朋友可能会问这样一个话,红色底纹它的数值是多少,回答是3,如果再问橄榄色的颜色值是多少呢?一下子答不上来,有些朋友可能会通过录制宏,先录制这种颜色的底纹,然后再Alt+F11 到VBE编辑窗口去看那橄榄色的颜色值,也是由于一个网友询问,我花了一点时间,把这个功能添加到完美工具箱里,同时还加了英文对照,效果下面的图
下载附件包
99.rar
(12.14 KB, 下载次数: 1332)
[code=vb]Sub 颜色与数字对照表()
Dim i As Integer, MyColor As Variant, k As Integer, h As Integer
MyColor = Array("黑色", "白色", "红色", "鲜绿色", "蓝色", "黄色", "粉红色", "青绿色", "深红色", "绿色", "深蓝色", "深黄色", "紫罗兰", "青色", "灰-25%", "灰-50%", "海螺色", "梅红色", "象牙色", "浅青绿", "深紫色", "珊瑚红", "海蓝色", "冰蓝", "深蓝色", "粉红色", "黄色", "青绿色", "紫罗兰", "深红色", "青色", "蓝色", "天蓝色", "浅青绿", "浅绿色", "浅黄色", "淡蓝色", "玫瑰红", "淡紫色", "茶色", "浅蓝色", "水绿色", "酸橙色", "金色", "浅橙色", "橙色", "蓝-灰", "灰-40%", "深青", "海绿", "深绿", "橄榄色", "褐色", "梅红色", "靛蓝", "灰-80%")
MyEColor = 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", "Lite 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%")
Range("A1:H30").Font.Size = 15
Range("A1:H30").Font.Name = "方正姚体"
Range("A2:H2").Font.Size = 17
Range("A2:H2").Font.ColorIndex = 5
' Range("A2:H2").Font.Bold = True
[D1].Font.Size = 26
[D1].Font.Bold = True
[D1].Font.ColorIndex = 3
[A2:H2] = Array("颜色显示", "颜色名", "数字值", "英文名", "颜色显示", "颜色名", "数字值", "英文名")
k = 3
h = 0
For i = 1 To 28
Cells(k, 1).Interior.ColorIndex = i '颜色
Cells(k, 2) = MyColor(h) '颜色名
Cells(k, 3) = i '颜色值
Cells(k, 4) = MyEColor(h) '英文名
Cells(k, 5).Interior.ColorIndex = i + 28 '颜色
Cells(k, 6) = MyColor(h + 28) '颜色名
Cells(k, 7) = i + 28 '颜色值
Cells(k, 8) = MyEColor(h + 28) '英文名
k = k + 1
h = h + 1
Next i
[D1] = "颜色值对照表"
Range("D1:G1").HorizontalAlignment = xlCenterAcrossSelection
Columns("A:H").EntireColumn.AutoFit
End Sub
Sub 清空()
[A1:H30].Clear
End Sub
[/code]
该贴已经同步到 佛山小老鼠的微博
|