我有一個很多數據(近14.000行和13列)的工作表。For循環設置字體和範圍的內部採取的方式太長
我在這張表中運行一個For
循環,但它有時需要2分鐘才能完成。此外,應用程序在For
循環中沒有響應。
有沒有一種方法可以重寫我的循環,使其運行速度快得多?
這裏是我的代碼:
For counter = 1 To Rows.Count
If Cells(counter, 13).Value > 500 Then
Cells(counter, 13).Interior.ColorIndex = 37
Cells(counter, 13).Font.Color = Black
Cells(counter, 13).Font.Bold = True
End If
count = count + 1
Application.StatusBar = count
Next counter
感謝提前:)。
使用條件格式? –
嘗試在開始時使用'Application.ScreenUpdating = False'封裝循環,最後使用'Application.ScreenUpdating = True'。 –
也不要在每次迭代循環時更新狀態欄。 – Rory