Sub KiemTra()
Dim shtData As Worksheet
Dim rngFind As Range, rngNgayThang As Range
Dim c As Long, e As Long, r As Long, col As Long
Set shtData = Worksheets("Sheet1")
e = shtData.Range("B" & shtData.Rows.Count).End(xlUp).Row
Set rngNgayThang = shtData.Range("C2:J2")
''Tim cot có ô fill màu do:
For Each rngFind In rngNgayThang
If rngFind.Interior.Color = 255 Then
col = rngFind.Column
Exit For
End If
Next
If col = 0 Then
rngNgayThang.Interior.Color = 255
MsgBox "Ban phai tô màu do tai 01 ô trên hàng ngày tháng câ`n so sánh!"
rngNgayThang.Interior.Pattern = xlNone
Exit Sub
End If
''Xóa fill màu:
rngNgayThang.Interior.Pattern = xlNone
shtData.Range("C3:J" & e).Interior.Pattern = xlNone
For r = 3 To e
For c = col - 1 To 3 Step -1
If shtData.Cells(r, c).Value > 0 Then
If shtData.Cells(r, c).Value > shtData.Cells(r, col).Value Then
shtData.Cells(r, c).Interior.Color = 65535
End If
Exit For
End If
Next
Next
End Sub