QuoteHi there,

I'm trying to sum values from different and multiple rows and send the result to an specific rows in another worksheet in the same work book. But with the code I made, I can only manage to get to work only one cell of row.

Can any one help me to se what is wrong with my code?

Thanks

Sub Test()

Dim Cell As Object

Dim NextRow As Long

Dim Cell2 As Object

Dim NextRow2 As Long

For Each Cell In Intersect(Range("B13,B21,B27,B37"), ActiveSheet.UsedRange)

If Cell.Value <> "" Then

' Determine the next full row

NextRow = Cell.Row

End If

Next

For Each Cell2 In Worksheets("PrintPage").Range("I20:I100")

If Cell2.Value = Cells(NextRow, 2).Value Then

NextRow2 = Cell2.Row

' Sum chosen cells M-02

If Cells(NextRow, 6).Value <> "" And ActiveSheet.Range("H6") = ActiveSheet.Range("B4") Then

Sum = Sheets("Printpage").Cells(NextRow2, 10).Value + Cells(NextRow, 6).Value

Sheets("Printpage").Cells(NextRow2, 10).Value = Sum

' Sum chosen cells M-05

ElseIf Cells(NextRow, 6).Value <> "" And ActiveSheet.Range("J6") = ActiveSheet.Range("B4") Then

Sum = Sheets("Printpage").Cells(NextRow2, 11).Value + Cells(NextRow, 6).Value

Sheets("Printpage").Cells(NextRow2, 11).Value = Sum

End If

End If

Next

End Sub