excel - excel中的单元格颜色
问题描述
我在excel中有一个数据表。我希望一旦任何单元格中的任何数据更新,单元格就会被着色。由于没有条件(除了单元格已更新),我无法使用条件格式来做到这一点。这可以通过 VBA 完成。
解决方案
右键单击工作表选项卡,然后选择“查看代码”。
然后输入以下内容:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Dim CellIntersect As Range
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("A1:C10")
Set CellIntersect = Application.Intersect(KeyCells, Target)
If Not CellIntersect Is Nothing Then
' Change background color to red
CellIntersect.Interior.Color = RGB(255, 0, 0)
End If
End Sub
如果您更改 KeyCells 范围内的任何单元格,在这种情况下颜色将变为红色。资料来源:这些 MS 文档与this相结合。
推荐阅读
- c# - 有没有办法在我的显示 api 内容的 uwp listview 上获取过滤器
- android - 在 Unity3D 中使用 dll-Library for Android Build
- c - CS50 复数编译失败
- python - 如何规避 AWS 包和大型包 + 大型模型的临时限制
- java - Java 8过滤字符串
- hibernate - 如何根据“整个单词”而不是包含对“使用 Lucene 休眠”的搜索结果进行排序
- vba - 如何使用 MS Access 连接到 Firebird SQL 数据库
- docker - Nginx 反向代理不提供静态文件
- java - JPQL,获取具有子列表的对象列表,避免 n+1 请求并且只选择特定字段
- android - 在活动之间从底部向上滑动动画