Jun 12 2021 02:06 AM
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 is a code -
What should i write in VBA code?
Please help..??
Here is a attach file..
Jun 12 2021 02:29 AM
SolutionTry 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 Sub
P.S. You can also use Conditional Formatting to highlight cells with a value greater than 10.
Jun 12 2021 02:36 AM - edited Jun 12 2021 03:10 AM
Sir, Can we write with the help of ActiveCell.Offset which i have written the code??
If yes,
then what should i write??
Jun 12 2021 03:16 AM
Selecting cells in a macro is very inefficient! You should avoid it.
Jun 12 2021 03:29 AM
Jun 12 2021 02:29 AM
SolutionTry 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 Sub
P.S. You can also use Conditional Formatting to highlight cells with a value greater than 10.