Andrea, take a look at the following code:
Dim sr1 As Long
Dim sr2 As Long
For sr1 = Sheets("Sheet1").Range("A2").CurrentRegion.Rows.Count To 2 Step -1
For sr2 = 1 To Sheets("Sheet2").Range("A2").CurrentRegion.Rows.Count
If Sheets("Sheet1").Cells(sr1, 1).Value = Sheets("Sheet2").Cells(sr2, 1).Value Then
Sheets("Sheet1").Cells(sr1, 9).Formula = "=SUM(B" & sr1 & ":H" & sr1 & ")"
The code goes through each value in column A
and looks for a match in column A
. If the value is found on Sheet2
, the code will insert a formula in column I
in the same row as the matched value on Sheet1
. The formula will sum the values in columns B-H
. Modify as necessary.