+ Reply to Thread
Results 1 to 4 of 4

Sum amount based on same reference id using VBA

  1. #1
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Los Angeles, USA
    MS-Off Ver
    2003, 2010, 365
    Posts
    320

    Sum amount based on same reference id using VBA

    Hi,

    If I have a excel 2003 file with a few rows/columns as follows


    ColumnA,ColumnB,ColumnC
    1234B,AB900,1
    1234B,AB900,1
    1244A,AB901,1
    1267B,AB906,2
    1279B,AB915,1
    1279B,AB915,3
    1279B,AB915,1
    1288A,AB922,2

    Is it possible to create a new line above each group of column A id and enter the total of column C using VBA relevant to the column A id as shown below.

    example after conversion:

    2
    1234B,AB900,1
    1234B,AB900,1
    1
    1244A,AB901,1
    2
    1267B,AB906,2
    4
    1279B,AB915,1
    1279B,AB915,3
    1279B,AB915,1
    2
    1288A,AB922,2


    Thanks for any help,

    David
    Last edited by djfscouse; 02-16-2013 at 02:00 AM.

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Sum amount based on same reference id using VBA

    Assuming that you data start in cell A1 you could try this macro.

    Please Login or Register  to view this content.
    Alf

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Sum amount based on same reference id using VBA

    Hi David

    Thanks for rep!

    Alf

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Sum amount based on same reference id using VBA

    Hi David

    Checking the macro I wrote I found it does not work right if the 3 first (or more) values in the A column are equal so I've written a fix for that. Do a test and see if you can find any problems.

    Please Login or Register  to view this content.
    Alf

+ 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