chingching831
New Member
- Joined
- Jun 2, 2022
- Messages
- 35
- Office Version
- 2019
- Platform
- Windows
Hi there,
I would like to use VBA code to highlight the highest values (cell in yellow, font in bold and red) of each row based on B2:G21.
May I know how the below VBA can be revised in order to achieve the expected result shown below?
I would like to use VBA code to highlight the highest values (cell in yellow, font in bold and red) of each row based on B2:G21.
May I know how the below VBA can be revised in order to achieve the expected result shown below?
VBA Code:
Sub Highlight_Max_Values_in_Rows()
ActiveSheet.UsedRange
Dim rA As Range, r, wf As WorksheetFunction
Dim V As Variant, RWW As Range, rr As Range
Set rA = Intersect(Range("A:A"), ActiveSheet.UsedRange)
Set wf = Application.WorksheetFunction
For Each r In rA
Set RWW = Intersect(r.EntireRow, ActiveSheet.UsedRange)
If wf.CountA(RWW) = 0 Then Exit Sub
V = wf.Max(RWW)
For Each rr In RWW
If rr.Value = V Then
rr.Interior.ColorIndex = 6
rr.Font.Bold = True
rr.Font.ColorIndex = 3
GoTo getaway
End If
Next rr
getaway:
Next r
End Sub