EXCEL中有什么函数或者方法能快速设置,不同地区用不同颜色表示?

我用条件格式的话,只能设置几个,但是如果有几十个话就不能设置了,这个要怎么设置比较好,不想用筛选,有点慢,想更便捷更快速的方式,各位大师,请赐教,谢谢

条件格式有限制,可以使用VBA实现,默认状态下可以标记56中不同颜色,扣除白色黑色外还剩54种。使用Alt+F11打开VBE编辑器,插入代码后录入代码,按F5运行,效果如下图示:

Alt+F11 代码窗口

运行效果

温馨提示:答案为网友推荐,仅供参考
第1个回答  2022-05-24
Sub 不同数填充不同色()
Dim Rng As Range, S#, CL&, Dic As Object, DicC As Object
Set Dic = CreateObject("Scripting.Dictionary")
Set DicC = CreateObject("Scripting.Dictionary")

CL = Rnd() * 256 * 256 * 256
For Each Rng In [a2].CurrentRegion
S = Rng
If Not Dic.Exists(S) Then
While DicC.Exists(CL): CL = Rnd() * 256 * 256 * 256: Wend
DicC(CL) = ""
Dic(S) = CL
Rng.Interior.Color = CL
Rng.Font.Color = -CL
Else
CL = Dic(S)
Rng.Interior.Color = CL
Rng.Font.Color = -CL
End If
Next Rng

Set DicC = Nothing
Set Dic = Nothing
End Sub
用代码直接设置颜色,只是颜色多了也很难用眼睛区分相近的颜色,另外有些颜色看不清字了。
相似回答