我正在尝试在电子表格上运行反向更新,以从一系列单元格中删除所有格式。迭代遍历单元格足够快,但是使内部引用显然会使代码显着减慢。
Set Rng1 = ThisWorkbook.Worksheets(ws.Name).Range("A17:bb300")
For Each c1 In Rng1
If c1.Interior.Pattern = xlSolid Then
With c1.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next c1
干杯
答案 0 :(得分:0)
或者您可以先确定所有单元格,然后一次格式化:
Dim Rng1 As Range, Rng2 As Range
Set Rng1 = ThisWorkbook.Worksheets(ws.Name).Range("A17:bb300")
For Each c1 In Rng1
If c1.Interior.Pattern = xlSolid Then
If Rng2 Is Nothing Then
Set Rng2 = c1
Else
Set Rng2 = Union(Rng2, c1)
End If
End If
Next c1
With Rng2.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With