Tirar totales macro más formato

Dante necesitaría agregar a este código que me hiciste este formato

Selection.NumberFormat = "$* #,##0;[Red]$ * -#,##0" para todos los totales y tambien en la macro que es automatica...........gracias

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    NextEnd Sub

1 Respuesta

Respuesta
1

La del módulo

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
            Cells(i, "E").NumberFormat = "$* #,##0;[Red]$ * -#,##0"
        End If
    Next
End Sub

La 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")))
            Cells(f.Row, "E").NumberFormat = "$* #,##0;[Red]$ * -#,##0"
        Next
    End If
End Sub

Dante discúlpame esta todo perfecto pero me olvide de pedirte una línea de codigopara colorear los totales es decir que queda así tanto manual como automática gracias

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
            Cells(i, "E").NumberFormat = "$* #,##0;[Red]$ * -#,##0"
            Cells(i, "E").Interior.Color = 49407
        End If
    Next
End Sub

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")))
            Cells(f.Row, "E").NumberFormat = "$* #,##0;[Red]$ * -#,##0"
            Cells(f.Row, "E").Interior.Color = 49407
        Next
    End If
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas