Excel返回或设置边框、字体或内部颜色

0表示无色

ColorIndex 属性 (Excel Graph)

返回或设置边框、字体或内部颜色,如中下表所示。 颜色可指定为当前调色板中颜色的索引值,也可指定为下列 XlColorIndex 常量之一:xlColorIndexAutomatic 或 xlColorIndexNone 。 读/写 Variant。

语法

expression .ColorIndex

表达式是必需的。 返回"应用于"列表中的一个对象的表达式。

注释

Object 说明
Border 边框的颜色。
Font 字体颜色。
Interior 填充的内部颜色。 将 ColorIndex 设置为 xlColorIndexNone ,以指定你不想进行内部填充。 将 ColorIndex 设置为 xlColorIndexAutomatic,以指定自动填充(适用于图形对象)。

此属性指定一种颜色作为调色板的索引。 下图展示了默认调色板中的颜色索引值。

示例

以下示例假定正在使用默认调色板。

以下示例设置数值轴主要网格线的颜色。

VB

vbscript 复制代码
With myChart.Axes(xlValue) 
 If .HasMajorGridlines Then 
 'Set color to blue 
 .MajorGridlines.Border.ColorIndex = 5 
 End If 
End With

以下示例将图表区内部颜色设置为红色,边框颜色设置为蓝色。

VB

vbscript 复制代码
With myChart.ChartArea 
 .Interior.ColorIndex = 3 
 .Border.ColorIndex = 5 
End With

参考链接

ColorIndex 属性 (Excel Graph) | Microsoft Learnhttps://learn.microsoft.com/zh-cn/office/vba/api/excel.colorindexExcel VBA Interior.ColorIndex 色彩列表 - Alice Sun - 博客园https://www.cnblogs.com/alicesunBlog/articles/2861089.html

特此记录

anlog

2026年5月20日

相关推荐
尤鸟倦5 天前
OneNote table复制到Excel遇到的各种问题
excel
2501_930707785 天前
使用C#代码使用条件格式为 Excel 隔行设置颜色
c#·excel
leihefeng5 天前
PX04-用 Python 读 Excel 画折线图,还能直接插回 Excel 文件
python·excel
yanlaifan6 天前
Excel中指定单元格不能输入内容的方法
excel
babe小鑫6 天前
信息与计算科学专业应届生面试 怎么证明自己能解决业务问题
学习·r语言·excel
Data-Miner7 天前
商品ABC分类分析怎么用AI做?脚本复用+图表可编辑的一次完整实操
人工智能·数据分析·excel
E-iceblue9 天前
Excel 列转行/行列转换全指南:从 4 种常见解法到 Python 批量自动化
python·excel·python库·spire.xls
Data-Miner9 天前
AI处理数据的脚本复用与逻辑复用有什么区别?哪种方式更能沉淀工作成果
数据分析·excel
福兮说10 天前
在浏览器里写一个“够用就好“的 Excel 公式求值器
前端·javascript·excel·编译原理
慧都小妮子10 天前
标签打印如何减少手工抄数?用Bartender 直连 Excel 批量打印
excel·bartender·条码打印·标签打印软件·数据驱动打印·工业打印机