Excel 在格式菜单下有一个条件格式...选项,允许您根据单元格的值更改单元格的样式/颜色/字体/任何内容。但它只允许三个条件。
如何让 Excel 根据单元格的值显示六种不同的背景单元格颜色? (即,如果值为“红色”,则将单元格设置为红色,如果值为“蓝色”,则将单元格设置为蓝色等)
最佳答案
您需要用 VBA 编写一些内容。
请参阅此处的示例:Get Around Excels 3 Criteria Limit in Conditional Formatting :
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:A10")) is Nothing Then
Select Case Target
Case 1 To 5
icolor = 6
Case 6 To 10
icolor = 12
Case 11 To 15
icolor = 7
Case 16 To 20
icolor = 53
Case 21 To 25
icolor = 15
Case 26 To 30
icolor = 42
Case Else
'Whatever
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub
关于excel - Excel 电子表格中的多个单元格背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/269267/