1
因此,我制作了一个有趣而简单的宏,它随机选择R,G和B值,直到它使用每种可能的组合(跳过重复),并用每种新颜色设置10x10方块的颜色值。Excel VBA:“太多不同的单元格格式” - 有没有办法在宏中删除或清除这些格式?
唯一的问题是,我已经遇到了单元格格式数量的限制。 Microsoft says that the limit should be around 64000,但我发现它是完全65429上的空白工作簿在Excel 2013年
我已经包含了明确的格式代码,但它似乎没有任何效果:
Cells(X, Y).ClearFormats
微软列出了一些决议,但其中的4个基本上是“不要制造太多格式”,而第四种格式是使用第三方应用程序。
在VBA中真的没有什么可以做的吗?
- A1:J10将打印出新的颜色
- K1将打印百分比完成
- L1将打印的颜色数量使用
M1将打印的次数数颜色组合重复
Dim CA(255, 255, 255) As Integer Dim CC As Long Dim RC As Long Dim R As Integer Dim G As Integer Dim B As Integer Dim X As Integer Dim Y As Integer CC = 0 RC = 0 X = 1 Y = 1 Do While ColorCount < 16777216 R = ((Rnd * 256) - 0.5) G = ((Rnd * 256) - 0.5) B = ((Rnd * 256) - 0.5) If CA(R, G, B) <> 1 Then CA(R, G, B) = 1 'Step down to the next row 'If at the 10th row, jump back to the first and move to the next column If X < 10 Then X = X + 1 Else X = 1 If Y < 10 Then Y = Y + 1 Else Y = 1 End If End If Cells(X, Y).ClearFormats 'doesn't do what I hope :( Cells(X, Y).Interior.Color = RGB(R, G, B) CC = CC + 1 Cells(1, 11).Value = (CC/16777216) * 100 Cells(1, 12).Value = CC Else RC = RC + 1 Cells(1, 13).Value = RC End If Loop
我其实不会说这个问题的解决方案是什么。但你在哪里更新'ColorCount'? – user3598756
颜色数组(“CA”)包含256x256x256个条目。如果CA(R,G,B)未设置为1,则将其设置为1(以考虑使用它)。然后,我将单元格的背景颜色设置得更低一些: 单元格(X,Y).Interior.Color = RGB(R,G,B) – MrMusAddict