Sub Main(Target)
Sh = Target.getSpreadsheet()
oCell() = Split(Target.AbsoluteName, ".")
oCellTarget = oCell(1)
If oCellTarget = "$H$1" Then
c = Sh.createCursor
c.gotoEndOfUsedArea(false)
LastRow = c.RangeAddress.EndRow
Ruota = Target.String
Sh.getCellrangeByName("I1:N"+LastRow+1).ClearContents(1+4)
Inizio = 6
ColIn = 8
For x = 2 To 12
if Sh.getCellByPosition(0, x).String = Ruota Then
exit for
end if
Next x
For i = 0 To 92 Step 23
Sh.getCellByPosition(ColIn, i).String = Sh.getCellByPosition(0, 0).String
Arr = Sh.getCellrangeByPosition(0, x, 5, x).GetDataArray
Sh.getCellrangeByPosition(ColIn, i+2, ColIn + 5, i+2).SetDataArray(Arr)
Next i
For i = 16 To LastRow
if Left(Sh.getCellByPosition(0, i).String, 10) = "Estrazione" Then
Sh.getCellByPosition(ColIn, Inizio).String = Sh.getCellByPosition(0, i).String
Inizio = Inizio + 2
elseif Sh.getCellByPosition(0, i).String = Ruota Then
Arr = Sh.getCellrangeByPosition(0, i, 5, i).GetDataArray
Sh.getCellrangeByPosition(ColIn, Inizio, ColIn + 5, Inizio).SetDataArray(Arr)
Inizio = Inizio + 21
End if
Next i
End if
End Sub