SommaIntervalloVariabile



  • SommaIntervalloVariabile
    di Jack88 (utente non iscritto) data: 27/11/2016 18:16:39

    Buonasera, non riesco a sommare le cell su un intervallo variabile.

    credo di sbagliare la sintassi nella definizione del Range.
    Mi potreste aiutare ?
     
    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



  • di patel data: 27/11/2016 18:24:39

    prova ora
     
    UltimaRiga = Worksheets.Item("DATI").Cells(Rows.Count, "C").End(xlUp).Row
    
    Set R161 = Worksheets("CALCOLO").Range("D5 : D" & UltimaRiga)