I've got the below piece of code in a macro:
And the part after <<SLOW PART>> runs in one case fine and in the other case slow. Not significantly slow but quite noticeably. In one case it's around 2 sec and in the other it's 8 sec. The only difference between these cases is that in the second case there are one extra worksheet to check for the name. I have counted the number of iterations (steps) and in the first case there are 200 steps and in the second 218 steps. So it's not that much to account for 6 seconds difference in execution. I wonder what could be a problem or what steps should I take to debug it?
VBA Code:
If UserForm1.wipe_format = True Then
Sheets("tables_for_output").Select
Range("F4:O4").Select
For Each r In Selection
r.Interior.Color = r.DisplayFormat.Interior.Color
Next r
Selection.FormatConditions.Delete
Range("B11:E20").Select
For Each r In Selection
r.Interior.Color = r.DisplayFormat.Interior.Color
Next r
Selection.FormatConditions.Delete
ActiveSheet.Range("A1").Select
''<<SLOW PART>>
For Each ws In Sheets
With ws
If .Visible Then
If UCase(ws.Name) Like "SET*" Then
ws.Select
Range("F6:I15").Select
For Each r In Selection
r.Interior.Color = r.DisplayFormat.Interior.Color
r.Value = r.Value
Next r
Selection.FormatConditions.Delete
ActiveSheet.Range("A1").Select
End If
End If
End With
Next ws
End If
And the part after <<SLOW PART>> runs in one case fine and in the other case slow. Not significantly slow but quite noticeably. In one case it's around 2 sec and in the other it's 8 sec. The only difference between these cases is that in the second case there are one extra worksheet to check for the name. I have counted the number of iterations (steps) and in the first case there are 200 steps and in the second 218 steps. So it's not that much to account for 6 seconds difference in execution. I wonder what could be a problem or what steps should I take to debug it?