If you move the columns N:Q of sheet 1 to the columns A:D of
Sheet 2 (with the name "Sheet2"), the macro changes as follows:
Sub macro2()
Dim lr1 As Integer, lr2 As Integer, p As Integer
lr2 = Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, 1).End(xlUp).Row
With Sheets("Sheet1")
lr1 = .Cells(.Rows.Count, 1).End(xlUp).Row
For x = 2 To lr1
For y = 2 To lr2
If Sheets("Sheet2").Cells(y, 1) = .Cells(x, 2) And Sheets("Sheet2").Cells(y, 2) = .Cells(x, 3) Then
For p = 5 To 9
If Sheets("Sheet2").Cells(y, 3) = .Cells(1, p) Then
.Cells(x, p) = Sheets("Sheet2").Cells(y, 4) * .Cells(x, 4)
End If
Next p
End If
Next y, x
End With
End Sub