excel - 如何在 Excel 中的多个选项卡中将特定单元格颜色更改为无填充?
问题描述
我目前正在尝试将工作簿中具有特定颜色的多个工作表的单元格更改为无填充。这是我在下面使用的代码。任何人都可以帮忙吗?
Sub YellowFillToNoFill()
'RGB(246, 244, 150) Yellow Colour To change to no Fill
'PURPOSE: Change any cell with a Yellow fill color to a No fill color
Dim cell As Range
'Optimize Code
Application.ScreenUpdating = False
'Ensure Cell Range Is Selected
If TypeName(Selection) <> "Range" Then
MsgBox "Please select some cells before running"
Exit Sub
End If
'Loop Through Each Cell
For Each cell In ActiveSheet.UsedRange 'Can also use Range("C1,C2" etc.) instead of
'Selection.Cells' or 'ActiveSheet.UsedRange'
If cell.Interior.Color = RGB(246, 244, 150) Then
cell.Interior.Color = xlNone
End If
Next
End Sub
解决方案
要重置该值,请使用 Usecell.Interior.ColorIndex = xlNone
Color
定义显示的颜色。它是一个long
包含颜色 RGB 值的值。
ColorIndex
是预定义颜色表(在 Excel 中选择颜色时看到的颜色表)的索引。特殊值xlNone
(-4142) 删除任何颜色设置。
推荐阅读
- c# - 测试发现器“NUnit3TestDiscoverer”加载测试时发生异常
- datatables - DataTables.net 从 CSV 导出中删除双引号
- database - SQL Loader 无法加载文件
- c# - IHTTPClientFactor 中的 NTLM 身份验证
- ruby-on-rails - 如何将我的 rails 自定义生成器连接到模型一?
- javascript - 为什么我的 javascript 会抛出“无法读取 null 的属性样式”?
- c# - VS Code 中的实体框架迁移
- git - Git远程是否有可能成为计算机本身的位置而不是网络位置?
- javascript - Socket IO多次发出代理消息
- algorithm - 图中的所有链