excel - VBA方法查看单元格是否改变颜色?
问题描述
我正在尝试更新我用来突出显示电子表格中的值的简短宏。是否存在检查细胞状态的方法?如果文本得到更新,我想将单元格的颜色改回白色。我不想只是将电子表格中的所有其他颜色都更改为白色,这不是一个有效的案例,因为我还有其他想要保留的颜色。我只想检查:
如果颜色已更改并且不再是有效案例,则将单元格重新着色为白色...
Private Sub CommandButton1_Click()
Dim itm As Range
Application.ScreenUpdating = False
For Each itm In ActiveSheet.UsedRange.Offset(1)
If Not IsError(itm) Then
With itm
Select Case .Value2
Case "GREEN", "green", "Green"
.Interior.Color = XlRgbColor.rgbLightGreen
Case "RED", "red", "Red"
.Interior.Color = XlRgbColor.rgbRed
Case "Serverely Delayed"
.Interior.Color = XlRgbColor.rgbRed
Case "Yellow", "yellow", "Yellow"
.Interior.Color = XlRgbColor.rgbYellow
Case "Delayed", "delayed"
.Interior.Color = XlRgbColor.rgbYellow
Case "Complete", "complete"
.Interior.Color = RGB(153, 204, 0)
End Select
End With
End If
Next
Application.ScreenUpdating = True
End Sub
解决方案
推荐阅读
- r - 为什么即使在 tm_map 函数中使用 content_transformer for tolower 后,我在 R 中的 DocumentTerm 矩阵中也会出现错误?
- angular - 如何在 HTML 元素属性值计算中使用 ngFor 索引变量?
- azure - 作为一名软件测试人员,我如何测试 Azure 数据湖中的数据?
- python - 使用 ssd_mobilenet_v2_quantized_300x300_coco 的目标检测模型的损失在每 10k-12k 步后增加
- javascript - 当我滚动时,我的导航栏颜色不想用我的 jquery 改变?
- kotlin - 为什么 Kotlin/Java 函数在实际使用中与文档看起来如此不同?
- reactjs - 变异 redux 在开发中保持状态
- excel - Excel函数拆分单元格
- python - 在 python 中解析 POSTed Excel 文件
- visual-studio-code - 多个框架的 VSCode 设置