Hey friends,
I have two sheets where I have the same colored cells that each have a number. On the first sheet I only want the numbers below 50 and in the other above 50.
I wrote a code for a command button to do so. The one code that deletes all the numbers above 50 takes about half a second to go through these ~12000 cells.
The second one takes over 2 minutes to delete the values below 50.
Does anybody know what factor there comes into play, that the second one is so much slower?
The codes are:
Delete values above 50:
Delete values below 50:
I have two sheets where I have the same colored cells that each have a number. On the first sheet I only want the numbers below 50 and in the other above 50.
I wrote a code for a command button to do so. The one code that deletes all the numbers above 50 takes about half a second to go through these ~12000 cells.
The second one takes over 2 minutes to delete the values below 50.
Does anybody know what factor there comes into play, that the second one is so much slower?
The codes are:
Delete values above 50:
Code:
Private Sub CommandButton1_Click()
For Each cell In Range("E14:EF108")
If cell.Value >= 50 Then
cell.ClearContents
cell.Interior.Color = RGB(255, 255, 255)
cell.Interior.Pattern = xlSolid
End If
Next cell
End Sub
Delete values below 50:
Code:
Private Sub CommandButton1_Click()
For Each cell In Range("E14:EF108")
If cell.Value < 50 Then
cell.ClearContents
cell.Interior.Color = RGB(255, 255, 255)
End If
Next cell
End Sub