
Sub Riassunto()
Dim R161 As Range
Dim UltimaRiga As Integer
UltimaRiga = Worksheets.Item("DATI").Cells(Rows.Count, "C").End(xlUp).Row
MsgBox UltimaRiga
Set R161 = Worksheets("CALCOLO").Range("D5 : D65") ' in questo modo funziona ma il range non è variabile
Set R161 = Worksheets("CALCOLO").Range(Cells(5, 4), Cells(UltimaRiga, 4)) ' in questo modo NON funziona: il range è variabile
Worksheets.Item("RIASSUNTO").Cells(2, "E").Value = Application.WorksheetFunction.Sum(R161)
End Sub |
UltimaRiga = Worksheets.Item("DATI").Cells(Rows.Count, "C").End(xlUp).Row
Set R161 = Worksheets("CALCOLO").Range("D5 : D" & UltimaRiga) |
