在 excel vba 中是否有更快的循环使用 ColorCounter 的方法?
is there a faster way to loop with ColorCounter in excel vba?
我有一个 lColorCounter 代码可以工作,但速度很慢。有没有更快的方法来使用 lColorCounter 循环?
Dim rng As Range
Dim lColorCounter As Long
Dim rngCell As Range
Set rng = Sheets("MASTER LINE LIST").Range("C2:Z2000")
lColorCounter = 0
For Each rngCell In rng
'Checking BLUE color
If Cells(rngCell.Row, rngCell.Column).DisplayFormat.Interior.Color = RGB(0, 176, 240) Then
lColorCounter = lColorCounter + 1
End If
Next
Sheets("Status").Range("C5") = lColorCounter
lColorCounter = 0
For Each rngCell In rng
'Checking Yellor color
If Cells(rngCell.Row, rngCell.Column).DisplayFormat.Interior.Color = RGB(255, 255, 0) Then
lColorCounter = lColorCounter + 1
End If
Next
Sheets("Status").Range("B5") = lColorCounter
循环一次:
Dim rng As Range
Dim bColorCounter As Long
Dim yColorCounter As Long
Dim rngCell As Range
Set rng = Worksheets("MASTER LINE LIST").Range("C2:Z2000")
bColorCounter = 0
yColorCounter = 0
For Each rngCell In rng
'Checking BLUE color
If rngCell.DisplayFormat.Interior.Color = RGB(0, 176, 240) Then
bColorCounter = bColorCounter + 1
ElseIf rngCell.DisplayFormat.Interior.Color = RGB(255, 255, 0) Then
yColorCounter = yColorCounter + 1
End If
Next
Sheets("Status").Range("C5") = bColorCounter
Sheets("Status").Range("B5") = yColorCounter
我有一个 lColorCounter 代码可以工作,但速度很慢。有没有更快的方法来使用 lColorCounter 循环?
Dim rng As Range
Dim lColorCounter As Long
Dim rngCell As Range
Set rng = Sheets("MASTER LINE LIST").Range("C2:Z2000")
lColorCounter = 0
For Each rngCell In rng
'Checking BLUE color
If Cells(rngCell.Row, rngCell.Column).DisplayFormat.Interior.Color = RGB(0, 176, 240) Then
lColorCounter = lColorCounter + 1
End If
Next
Sheets("Status").Range("C5") = lColorCounter
lColorCounter = 0
For Each rngCell In rng
'Checking Yellor color
If Cells(rngCell.Row, rngCell.Column).DisplayFormat.Interior.Color = RGB(255, 255, 0) Then
lColorCounter = lColorCounter + 1
End If
Next
Sheets("Status").Range("B5") = lColorCounter
循环一次:
Dim rng As Range
Dim bColorCounter As Long
Dim yColorCounter As Long
Dim rngCell As Range
Set rng = Worksheets("MASTER LINE LIST").Range("C2:Z2000")
bColorCounter = 0
yColorCounter = 0
For Each rngCell In rng
'Checking BLUE color
If rngCell.DisplayFormat.Interior.Color = RGB(0, 176, 240) Then
bColorCounter = bColorCounter + 1
ElseIf rngCell.DisplayFormat.Interior.Color = RGB(255, 255, 0) Then
yColorCounter = yColorCounter + 1
End If
Next
Sheets("Status").Range("C5") = bColorCounter
Sheets("Status").Range("B5") = yColorCounter