第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
用代码直接设置颜色,只是颜色多了也很难用眼睛区分相近的颜色,另外有些颜色看不清字了。