Here are two macros - one using your formula, the other using a loop:
Sub Macro1()
With Range("J2:J13")
.FormulaR1C1 = "=SUM(" & _
"VLOOKUP(R1C[-8],R2C16:R9C17,2,FALSE)*RC[-8]," & _
"VLOOKUP(R1C[-7],R2C16:R9C17,2,FALSE)*RC[-7]," & _
"VLOOKUP(R1C[-6],R2C16:R9C17,2,FALSE)*RC[-6]," & _
"VLOOKUP(R1C[-5],R2C16:R9C17,2,FALSE)*RC[-5]," & _
"VLOOKUP(R1C[-4],R2C16:R9C17,2,FALSE)*RC[-4]," & _
"VLOOKUP(R1C[-3],R2C16:R9C17,2,FALSE)*RC[-3]," & _
"VLOOKUP(R1C[-2],R2C16:R9C17,2,FALSE)*RC[-2]," & _
"VLOOKUP(R1C[-1],R2C16:R9C17,2,FALSE)*RC[-1])"
.Value = .Value
End With
End Sub
Sub Macro2()
Dim c As Range
Dim lngC As Long
Dim lngR As Long
Dim temp As Double
For Each c In Range("J2:J13")
temp = 0
For lngC = 2 To 9
temp = temp + Application.VLookup(Cells(1, lngC).Value, Range("P2:Q9"), 2, False) * Cells(c.Row, lngC).Value
Next lngC
c.Value = temp
Next
End Sub
Bookmarks