Forum Discussion
Excel
Jun 12, 2021Iron Contributor
Question related to loops
Hello Everyone, I have created code which those value greater than 10, then it highlight red in colour. It works in 1st column, but not jump to 2nd column to highlight. like - And Here ...
- Jun 12, 2021
Try this:
Public Sub FunWithLoop() Dim cel As Range Application.ScreenUpdating = False For Each cel In ActiveSheet.UsedRange If IsNumeric(cel.Value) Then If cel.Value > 10 Then cel.Interior.Color = vbRed End If End If Next cel Application.ScreenUpdating = True End SubP.S. You can also use Conditional Formatting to highlight cells with a value greater than 10.
HansVogelaar
Jun 12, 2021MVP
Selecting cells in a macro is very inefficient! You should avoid it.
Excel
Jun 12, 2021Iron Contributor
Thank you so much sir😊😊