Sub calcola()
Dim X As Long, Y As Long, R As Long, Area As Range, Riga As Object, Ruolo As String
Set Area = Range("L15:L21")
Range("K3:M21").ClearContents
For X = 3 To 21
If Cells(X, 4) <> "s.v." And Cells(X, 4) <> "" Then Cells(X, 11) = Cells(X, 2)
If Cells(X, 4) <> "s.v." And Cells(X, 4) <> "" Then Cells(X, 12) = Cells(X, 3)
If Cells(X, 4) <> "s.v." And Cells(X, 4) <> "" Then Cells(X, 13) = Cells(X, 4)
Next X
For X = 3 To 13
If Cells(X, 13) = "" Then
Ruolo = Cells(X, 3)
Set Riga = Area.Find(Ruolo, LookIn:=xlValues, LookAt:=xlWhole)
If Riga Is Nothing Then
Cells(X, 11) = "VUOTO"
Else
R = Riga.Row
If Cells(R, 12) > 0 Then
Cells(X, 11) = Cells(R, 11)
Cells(X, 13) = Cells(R, 13)
Cells(X, 13) = Cells(R, 13)
Cells(R, 11) = ""
Cells(R, 12) = ""
Cells(R, 13) = ""
Y = Y + 1
If Y > 3 Then Exit For
End If
End If
End If
Next X
End Sub
|