[vba]

Sub ColourCells()
Dim sh As Worksheet
Dim lastRow As Long
Dim rowProduct As Long
Dim colProduct As Long
Dim colMonth As Long
Dim colType As Long
Dim i As Long

Set sh = Worksheets("Sheet2")
sh.Range("C3").Resize(3, 3).Value = "M"
sh.Range("G3").Resize(3, 3).Value = "M"

With Worksheets("Sheet1")

lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow

If .Cells(i, "C").Value <> "" Then

If Month(.Cells(i, "B").Value) = 9 Then

colMonth = 2
Else

colMonth = 6
End If

colType = Application.Match(.Cells(i, "C").Value, sh.Cells(2, colMonth + 1).Resize(, 3), 0)
rowProduct = Application.Match(.Cells(i, "A").Value, sh.Columns(colMonth), 0)
sh.Cells(rowProduct, colMonth + colType).Value = ""
End If
Next i
End With
End Sub[/vba]