Sub nota()
Dim rng As Range
Dim cella As Range
Dim y As Integer
Dim tabella As Range
Dim somma As Range
Sheets("foglio1").Activate
Sheets("foglio1").Range("a22:k100000").ClearContents
Sheets("foglio1").Range("a22:k100000").ClearFormats
y = 2
With Sheets("elenco 3")
Set rng = Range(.Cells(2, 8), .Cells(2, 8).End(xlDown))
For Each cella In rng
If cella.Offset(0, 5) = "si" Or cella.Offset(0, 5) = "SI" Then
cella.Offset(0, 4).Copy Destination:=Cells(y + 20, 10)
cella.Offset(0, 3).Copy Destination:=Cells(y + 20, 9)
cella.Offset(0, 2).Copy Destination:=Cells(y + 20, 8)
cella.Offset(0, 1).Copy Destination:=Cells(y + 20, 7)
cella.Offset(0, -2).Copy Destination:=Cells(y + 20, 6) ' costo
cella.Offset(0, -3).Copy Destination:=Cells(y + 20, 5)
cella.Offset(0, -4).Copy Destination:=Cells(y + 20, 4)
cella.Offset(0, -5).Copy Destination:=Cells(y + 20, 3)
cella.Offset(0, -6).Copy Destination:=Cells(y + 20, 2)
cella.Offset(0, -7).Copy Destination:=Cells(y + 20, 1)
cella.Copy Destination:=Cells(y + 20, 11)
y = y + 1
End If
Next cella
End With
With Sheets("foglio1")
Set tabella = Range(.Cells(22, 1), .Cells(22, 11).End(xlDown))
tabella.Borders.LineStyle = xlDot
Set somma = Range([I22], [I22].End(xlDown)) ' imposto range per somma
[I22].End(xlDown).Select 'seleziono ultima cella
ActiveCell.Offset(4, 0) = WorksheetFunction.Sum(somma) 'mi sposto ed eseguo somma
ActiveCell.Offset(4, 0).Font.Bold = True
ActiveCell.Offset(4, -1) = "Totale"
ActiveCell.Offset(4, -1).Font.Bold = True
ActiveCell.Offset(4, -1).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, -2).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, -3).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, -4).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, -5).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, -6).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, -7).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, -8).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, 0).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, 1).Interior.Color = RGB(217, 217, 217)
ActiveCell.Offset(4, 2).Interior.Color = RGB(217, 217, 217)
End With
End Sub |