Is this what you are after?
[VBA]Sub Formats()
Dim r As Range
Dim cel As Range
Set r = Range("E7:V29")
For Each cel In r
If Cells(cel.Row, 2) = Cells(5, cel.Column) Then cel.Interior.ColorIndex = 3
If Cells(cel.Row, 3) = Cells(5, cel.Column) Then cel.Interior.ColorIndex = 4
Next
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.