网站模版,wordpress怎么修改图片,现在用什么做网站,代码编程教学入门软件标题 ExcelVBA编程输出ColorIndex与对应颜色色谱 正文 解决问题编程输出ColorIndex与对应色谱共56#xff0c;打算分4纵列输出#xff0c;标题是ColorIndex,Color,Name 1. 解释VBA中的ColorIndex属性 在VBA#xff08;Visual Basic for Applications#xff09;中#xff… 标题 ExcelVBA编程输出ColorIndex与对应颜色色谱 正文 解决问题编程输出ColorIndex与对应色谱共56打算分4纵列输出标题是ColorIndex,Color,Name 1. 解释VBA中的ColorIndex属性 在VBAVisual Basic for Applications中 Interior.ColorIndex 属性用于设置或返回单元格或范围内部的颜色索引。这个属性是Excel内置颜色集合的一个引用通过指定一个数字来选择一个颜色。与直接使用RGB颜色值不同 ColorIndex 提供了一种更简单的方式来引用一组预定义的颜色,它使用一个整数值来表示颜色这个整数值对应于 Excel 内置的颜色索引。颜色索引的范围是 1 到 56其中 1 表示黑色2 表示白色3 表示红色依此类推。 2.收集Color的中文名 来源于网络按序号1-56黑色、白色、色、鲜绿色、蓝色、黄色、粉红色、青绿色、深红色、绿色、深蓝色、深黄色、装咽火、青色、灰-25%、灰-50%、海螺色、梅红色、象牙色、浅青绿、深紫色、珊瑚红、海蓝色、冰蓝、深蓝色、粉红色、黄色、青绿色、紫罗兰、深红色、青色、蓝色、天蓝色、浅青绿、浅绿色、浅黄色、淡蓝色、玫瑰红、淡紫色、茶色、浅蓝色、水绿色、酸橙色、金色、浅橙色、色、蓝-灰、灰-40%、深青、海绿、深绿、色、色、梅红色、靛蓝、灰-80% 3.解决思路 考虑到输出界面大小 3-1.把56分4纵列输出 3-2.标题3列是Array(ColorIndex, Name, Color)共需要4*312列 3-3.从for i1 to 56,从第2行起输出每次要输出ColorIndex,Name, Color,三个数据 3-4.每到56/4后再从第2起开始输出 4.效果图 5.示例代码 通过多次测试成功。其中有编程输出的方式可供大家学习 可供学习知识点数据的循环中的标题输出坐标输出数组输出 由于要多次输出测试所以用一个清除Sub clear清除()Cells.ClearEnd Sub’用于输出ColorIndex与颜色对照表Sub CreateColorIndexAndColor()Dim rowN As IntegerDim colN As IntegerDim row_i As IntegerDim col_i As IntegerDim rng As RangeDim partCol As IntegerDim partRow As IntegerDim r As RangeDim Num As IntegerDim ColorName As StringDim ColorArr As VariantDim NameArr As VariantNameArr Array(ColorIndex, Name, Color)ColorName 黑色、白色、色、鲜绿色、蓝色、黄色、粉红色、青绿色、深红色、绿色、深蓝色、深黄色、装咽火、青色、灰-25%、灰-50%、海螺色、梅红色、象牙色、浅青绿、深紫色、珊瑚红、海蓝色、冰蓝、深蓝色、粉红色、黄色、青绿色、紫罗兰、深红色、青色、蓝色、天蓝色、浅青绿、浅绿色、浅黄色、淡蓝色、玫瑰红、淡紫色、茶色、浅蓝色、水绿色、酸橙色、金色、浅橙色、色、蓝-灰、灰-40%、深青、海绿、深绿、色、色、梅红色、靛蓝、灰-80%Num 56colN 3rowN 1row_i 0col_i 0partCol 4partRow Num / 4ColorArr Split(ColorName, 、)With ActiveSheet For Each r In .Range(A1).Resize(1, partCol * colN) r.Value NameArr((r.Column - 1) Mod colN) Next With .Range(A1).Resize(1, partCol * colN) .Font.Bold True End With For i 1 To Num Set rng .Cells(row_i rowN 1, col_i 1) rng i rng.Offset(0, 1).Value ColorArr(i - 1) rng.Offset(0, 2).Interior.ColorIndex i row_i row_i 1 If i Mod partRow 0 Then row_i 0 col_i col_i colN End If Set rng Nothing Next With .UsedRange .HorizontalAlignment xlCenter .VerticalAlignment xlCenter .ColumnWidth 9.5 .RowHeight 30 .Borders.LineStyle 1 End WithEnd WithEnd Sub 6.相关知识链接 在VBA中Interior.Color如何应用举例说明 在VBA中编程中的颜色的RGB ExcelVBA实现单元格背景颜色与RGB值互转 在VBA中Interior.ColorIndex属性及其应用举例说明 正文结束 更多合集 Excel VBA学习系列汇总20241205 *** 关注转发点赞在看