Issue Totalling Amount with Macro

Copper Contributor

Hi Everyone,

 

Would like your expertise on this issue that I have.

Currently have figured out:

Sub AutoSum()

    Const SourceRange = "D:E"

    Dim NumRange As Range, formulaCell As Range

    Dim SumAddr As String

    Dim c As Long

 

    For Each NumRange In Columns("D").SpecialCells(xlConstants, xlNumbers).Areas

        SumAddr = NumRange.Address(False, False)

        Set formulaCell = NumRange.End(xlUp).Offset(1, 0).Resize(1, 1)

        formulaCell.Formula = "=SUM(" & SumAddr & ")"

 

        c = NumRange.Count

    Next NumRange

 

As shown in this diagram below:

1.jpg

 

That said, I would need to total up two separate columns from the same date as a total which I cannot have it figured out at all. Sample output ideally would look something like the following:

2.jpg

 

Logic should go as follows:

If amount and tax amount falls on the same date, it will be totaled up to the respective cells in red.

 

Thank you.

 

0 Replies