Macro que recorra un rango y me tire totales

Necesito una macro que me tire los totales en la columna E o sea mientras haya un fecha

En la columna A me sume de B a D y me tire el total o sea:

en E2 = 120

     E3 = 23

     E4 = 80

    E5 =   0

     E6 = 200

Y cuando no hay más fechas la macro se detiene, muchas gracias

1 Respuesta

Respuesta
1

Te anexo la macro

Sub TirarTotales()
'Por.Dante Amor
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
        If IsDate(Cells(i, "A")) Then
            wsum = WorksheetFunction.Sum(Range(Cells(i, "B"), Cells(i, "D")))
            Cells(i, "E") = wsum
        End If
    Next
End Sub

Si quieres que funcione en automático, pon esto en los eventos de la hoja:

Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
    If Not Intersect(Target, Range("A:D")) Is Nothing Then
        For Each f In Target.Rows
            Cells(f.Row, "E") = WorksheetFunction.Sum(Range(Cells(f.Row, "B"), Cells(f.Row, "D")))
        Next
    End If
End Sub

Saludos.Dante Amor

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas