Macro: Find Duplicate Values & Sum Values. Per Day Basis

  • I have data that looks like this:
    day# id amount
    1 56575 0
    1 56675 0
    1 56680 0
    1 56683 0
    1 56681 0
    1 51810 0
    1 51810 0
    1 51810 0
    2 58206 0.0147
    2 50001 0.0036
    2 58212 0.5106
    2 58212 0.0058
    3 56675 1
    3 56675 0


    How do you write an excel macro that looks at the number in the first column (day #) and finds all the duplicate id#s in the second column that are in day 1and adds the amounts together in the 3rd column then writes the first column number (day#), second column number(id#) and the third column (sum of the amounts of duplicate Id#) to an new worksheet. Then the macro would loop through day #2 and do the same thing. Notice that the values in the id column are unique in this data set below this is how I would like the data to look. I have accomplished this in a pivot table but my problem is I need a cvs file to export the final data into an external database which is why I need a macro. Thanks
    day# id amount
    1 56575 0
    1 56675 0
    1 56680 0
    1 56683 0
    1 56681 0
    1 51810 0
    2 58206 0.0147
    2 50001 0.0036
    2 58212 0.5146
    3 56675 1

  • Re: Macro To Find Duplicate Id Values And Sum Those Values On A Per Day Basis


    Have you considered using the Pivot Table command?


    m

  • Re: Macro To Find Duplicate Id Values And Sum Those Values On A Per Day Basis


    Quote from mhabib

    Have you considered using the Pivot Table command?


    m


    I ended up using a macro thanks!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!