Antonio
What you need is more suited to a macro. Assuming that your spreadsheet is
the same as the uploaded file then the following will work for you. It does
return different, but correct results from your data.
Sub test()
Dim LastRow As Long
Dim MyTable As Range, MyList As Range
Dim d, f
Range("C1").Activate
LastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
Set MyTable = Range("F2:K7")
Set MyList = Range(Cells(2, 3), Cells(LastRow, 3))
MyTable = 0
For i = 2 To LastRow - 1
d = Cells(i, 3)
f = Cells(i + 1, 3)
Select Case f
Case 1
If d = 1 Then Cells(2, 6) = Cells(2, 6) + 1
If d = 2 Then Cells(2, 7) = Cells(2, 7) + 1
If d = 3 Then Cells(2, 8) = Cells(2, 8) + 1
If d = 4 Then Cells(2, 9) = Cells(2, 9) + 1
If d = 5 Then Cells(2, 10) = Cells(2, 10) + 1
If d = 6 Then Cells(2, 11) = Cells(2, 11) + 1
Case 2
If d = 1 Then Cells(3, 6) = Cells(3, 6) + 1
If d = 2 Then Cells(3, 7) = Cells(3, 7) + 1
If d = 3 Then Cells(3, 8) = Cells(3, 8) + 1
If d = 4 Then Cells(3, 9) = Cells(3, 9) + 1
If d = 5 Then Cells(3, 10) = Cells(3, 10) + 1
If d = 6 Then Cells(3, 11) = Cells(3, 11) + 1
Case 3
If d = 1 Then Cells(4, 6) = Cells(4, 6) + 1
If d = 2 Then Cells(4, 7) = Cells(4, 7) + 1
If d = 3 Then Cells(4, 8) = Cells(4, 8) + 1
If d = 4 Then Cells(4, 9) = Cells(4, 9) + 1
If d = 5 Then Cells(4, 10) = Cells(4, 10) + 1
If d = 6 Then Cells(4, 11) = Cells(4, 11) + 1
Case 4
If d = 1 Then Cells(5, 6) = Cells(5, 6) + 1
If d = 2 Then Cells(5, 7) = Cells(5, 7) + 1
If d = 3 Then Cells(5, 8) = Cells(5, 8) + 1
If d = 4 Then Cells(5, 9) = Cells(5, 9) + 1
If d = 5 Then Cells(5, 10) = Cells(5, 10) + 1
If d = 6 Then Cells(5, 11) = Cells(5, 11) + 1
Case 5
If d = 1 Then Cells(6, 6) = Cells(6, 6) + 1
If d = 2 Then Cells(6, 7) = Cells(6, 7) + 1
If d = 3 Then Cells(6, 8) = Cells(6, 8) + 1
If d = 4 Then Cells(6, 9) = Cells(6, 9) + 1
If d = 5 Then Cells(6, 10) = Cells(6, 10) + 1
If d = 6 Then Cells(6, 11) = Cells(6, 11) + 1
Case 6
If d = 1 Then Cells(7, 6) = Cells(7, 6) + 1
If d = 2 Then Cells(7, 7) = Cells(7, 7) + 1
If d = 3 Then Cells(7, 8) = Cells(7, 8) + 1
If d = 4 Then Cells(7, 9) = Cells(7, 9) + 1
If d = 5 Then Cells(7, 10) = Cells(7, 10) + 1
If d = 6 Then Cells(7, 11) = Cells(7, 11) + 1
End Select
Next
End Sub
Press Alt + F11, Insert module then paste the code. close and return to
file. make sure that you are in the right sheet and run the code.
Regards
Peter
Ps sorry for the delay, I share the computer and my ISP was down this morning.