快速格式化Excel中的单元格 [英] Quickly format cells in excel
本文介绍了快速格式化Excel中的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在电子表格上运行反向更新,以从一系列单元格中删除所有格式。迭代单元格是足够快的,但内部引用似乎会使代码减慢。
I am trying to run a reverse update on a spreadsheet to remove all formatting from a range of cells. iterating through the cells is quick enough however making the internal reference appears to slow the code down dramatically.
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
干杯
推荐答案
或者您可以先确定所有单元格,然后格式化一次:
Or you can determine all the cells first, then format in one go:
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
这篇关于快速格式化Excel中的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文