Conditional Formating Excel Table

flipland

New Member
Joined
Mar 26, 2019
Messages
9
Hi. I would like to have conditional formatting done on an Excel Table based on the MIN and MAX values of every row in the table. Cells of the MIN values are to be highligted in RED with WHITE font. Celss of the MAX values are to be highlighted in GREEN with WHITE font.

I was able to find VBA code to conditionally format by row, but am stuck as to how to make it loop down to the next row. The code is copy-pasted below, as well as a snippet of the table. Would appreciate any help on this. Thanks!

CODE:
Public Sub MIN_MAX_Format()

ActiveSheet.Range("A1").Select
ActiveCell.Offset(1, 1).Select
Range("b2:r2").Select


Dim rg As Range
Dim cond1 As FormatCondition, cond2 As FormatCondition, cond3 As FormatCondition
Set rg = ActiveSheet.Range("B2:R2")

'clear any existing conditional formatting
rg.FormatConditions.Delete

'define the rule for each conditional format
Set cond1 = rg.FormatConditions.Add(xlCellValue, xlEqual, "=$U2")
Set cond2 = rg.FormatConditions.Add(xlCellValue, xlEqual, "=$T2")

'define the format applied for each conditional format
With cond1
.Interior.Color = vbGreen
.Font.Color = vbWhite
End With

With cond2
.Interior.Color = vbRed
.Font.Color = vbWhite
End With

ActiveCell.Offset(1, 0).Select


End Sub



The table looks like this:

https://drive.google.com/file/d/1yTWNE9WaHTzBJRUfXZ_VKq5v8ZdJZdFf/view?usp=sharing

[TABLE="width: 1344"]
<tbody>[TR]
[TD]Country Name[/TD]
[TD]Bangladesh[/TD]
[TD]Bhutan[/TD]
[TD]China[/TD]
[TD]Hong Kong SAR, China[/TD]
[TD]Indonesia[/TD]
[TD]Japan[/TD]
[TD]Lao PDR[/TD]
[TD]Sri Lanka[/TD]
[TD]Macao SAR, China[/TD]
[TD]Myanmar[/TD]
[TD]Malaysia[/TD]
[TD]Nepal[/TD]
[TD]Philippines[/TD]
[TD]Singapore[/TD]
[TD]Thailand[/TD]
[TD]Vietnam[/TD]
[TD="colspan: 2"]Korea, Rep.[/TD]
[TD]MIN[/TD]
[TD]MAX[/TD]
[/TR]
[TR]
[TD]1960[/TD]
[TD]89[/TD]
[TD][/TD]
[TD]90[/TD]
[TD]429[/TD]
[TD][/TD]
[TD]479[/TD]
[TD][/TD]
[TD]143[/TD]
[TD][/TD]
[TD][/TD]
[TD]235[/TD]
[TD]51[/TD]
[TD]254[/TD]
[TD]428[/TD]
[TD]101[/TD]
[TD][/TD]
[TD]158[/TD]
[TD][/TD]
[TD]51[/TD]
[TD]479[/TD]
[/TR]
[TR]
[TD]1961[/TD]
[TD]97[/TD]
[TD][/TD]
[TD]76[/TD]
[TD]437[/TD]
[TD][/TD]
[TD]564[/TD]
[TD][/TD]
[TD]143[/TD]
[TD][/TD]
[TD][/TD]
[TD]226[/TD]
[TD]52[/TD]
[TD]267[/TD]
[TD]449[/TD]
[TD]107[/TD]
[TD][/TD]
[TD]94[/TD]
[TD][/TD]
[TD]52[/TD]
[TD]564[/TD]
[/TR]
[TR]
[TD]1962[/TD]
[TD]100[/TD]
[TD][/TD]
[TD]71[/TD]
[TD]488[/TD]
[TD][/TD]
[TD]634[/TD]
[TD][/TD]
[TD]139[/TD]
[TD][/TD]
[TD][/TD]
[TD]230[/TD]
[TD]55[/TD]
[TD]157[/TD]
[TD]472[/TD]
[TD]114[/TD]
[TD][/TD]
[TD]106[/TD]
[TD][/TD]
[TD]55[/TD]
[TD]634[/TD]
[/TR]
</tbody>[/TABLE]
 
You're welcome & thanks for the feedback
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,952
Messages
6,175,593
Members
452,654
Latest member
mememe101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top