+ Reply to Thread
Results 1 to 5 of 5

Need a macro to total different lines and move total to new cell

  1. #1
    Registered User
    Join Date
    01-24-2012
    Location
    PA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Need a macro to total different lines and move total to new cell

    I need a macro that will total numbers from duplicate entries and move the totals to new cells. As you can see on the attached sample the name "Albright" has two lines of amounts. I would need the total of F2 and F3 placed in I2, it would also have to total and move G2 and G3, H2 and H3 to J2 and K2 respectively. I would have to run the macro manually as I have 3500 lines with these double entries stuck in at different places. My active cell in this instance would be A2 I would run the macro it would do the calculations, move the totals then delete the duplicate row. I have made other macros to move and delete rows but never had one with a formula in it. Thanks for all the help.
    Attached Files Attached Files

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    1,699

    Re: Need a macro to total different lines and move total to new cell

    Try this on a copy of your data...
    Please Login or Register  to view this content.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    15,362

    Re: Need a macro to total different lines and move total to new cell

    Hi cmefix and welcome to the forum,

    This problem looks like a Pivot Table Answer to me. See the attached to see if it does what you need without code or formulas.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    01-24-2012
    Location
    PA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need a macro to total different lines and move total to new cell

    MarvinP the pivot table would work on a smaller scale unfortunately I am working with some very large work sheets with too many odd variables but thank you.

    Dangelor at first your macro would not work, I tried it again on the sample and it worked fine. I then debugged it and not really knowing how to write a macro such at this I was stumped. But the longer I looked at it the more I picked up what the numbers meant! The debugger stopped at vD(x, 10) = vD(x, 7) + vD(x + 1, 7) and finally understanding what the numbers meant I looked down column 7 and found improperly formatted numbers. I just knew it was going to run after I cleaned them up and wow did it, 3500 lines processed with the click of a button. I have 4 more spread sheets to get to, this time I will clean them up ahead of time. I can see I have a lot to learn going from my simple cut and move macros to this.

    Thank you both for replying to this I really appreciate it. Dangelor you saved me big time thank you.

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    1,699

    Re: Need a macro to total different lines and move total to new cell

    Glad I could help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1