+ Reply to Thread
Results 1 to 8 of 8

Macro to obtain subtotal of unique combinason

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    24

    Macro to obtain subtotal of unique combinason

    Hi,

    Again I would need some help to try and facilitate a very lengthy task.

    Attached is a my data. From column A to D.

    I need to get the subtotal for the column C (Total) and D (Qty) for all unique combination of columns A and B. Moreover, I would need it in the format given from column G.

    Note that:
    1. This is only a very small sample. I can have up to around 20 different Ref in column A.
    2. The type under each Ref (after running the macro) should be in ascending order.
    3. Only existing type under each Ref should be included.

    Well, I started doing the filter option but its too lengthy. I have also tried the subtotal option but again my data is too long. Please help.
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Macro to obtain subtotal of unique combinason

    Try this macro

    Please Login or Register  to view this content.
    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007/2010.
    Martin

  3. #3
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Macro to obtain subtotal of unique combinason

    Hi
    msls

    u can use pivot table for easy way i have attached it pls check
    Attached Files Attached Files
    Happy to Help

    VISHA

    Click *, if the suggestion helps you!
    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>> "Mark your thread as Solved"

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to obtain subtotal of unique combinason

    Try the attached workbook. Note the results are written to Sheet2. I think the result data provided by you is not entirely correct. For example I do not see an aggregated total & quantity for A P134004 while the combination does exist in the data, I am therefore assuming the results in column G are shown for the desired layout only.
    Attached Files Attached Files
    If you like my contribution click the star icon!

  5. #5
    Registered User
    Join Date
    08-21-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro to obtain subtotal of unique combinason

    Dear OllieB and mrice,

    I apologize for the late reply but I was on holidays for a week. Kindly note that I am still unable to run it. Both your macros work just fine on Excel 2007 but bugs when it comes to Excel 2003 (which most users have here!).

    I had a look at mrice's macro - and I believe that it would be the sumifs function (which is not possible in MS 2003). As for OllieB, it seems that MS Excel 2003 does not run the "SortOn:=xlSortOnValues" function.

    Kindly help.

    msls09

  6. #6
    Registered User
    Join Date
    08-21-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro to obtain subtotal of unique combinason

    Dear mrice,

    I apologize for the late reply but I was on holidays for a week. Kindly note that I am still unable to run it. Both your macros work just fine on Excel 2007 but bugs when it comes to Excel 2003 (which most users have here!).

    I had a look at your macro - and I believe that it would be the sumifs function (which is not possible in MS 2003). It also seems that MS Excel 2003 does not run the "SortOn:=xlSortOnValues" function.

    Kindly help.

    msls09

  7. #7
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to obtain subtotal of unique combinason

    Hi msls09,
    try it
    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to obtain subtotal of unique combinason

    Quote Originally Posted by msls09 View Post
    Dear OllieB and mrice,

    I apologize for the late reply but I was on holidays for a week. Kindly note that I am still unable to run it. Both your macros work just fine on Excel 2007 but bugs when it comes to Excel 2003 (which most users have here!).

    I had a look at mrice's macro - and I believe that it would be the sumifs function (which is not possible in MS 2003). As for OllieB, it seems that MS Excel 2003 does not run the "SortOn:=xlSortOnValues" function.

    Kindly help.

    msls09
    The "SortOn:=xlSortOnValues" is present in both solutions, so if it works in the solution of mrice, it cannot be the problem in mine.

+ 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