+ Reply to Thread
Results 1 to 11 of 11

Sum array (or something) based on multiple criteria

  1. #1
    Registered User
    Join Date
    06-18-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Sum array (or something) based on multiple criteria

    Hi,

    Have a big problem - don't know If its possible to solve it with VBA. If the socialsec, date, fruit is same then save it into a temp or something sum quantity and print out as 1 line else different rows.

    Have a sheet with following data:

    SocialSec Date Fruit Quantity
    12345 2015-02-02 Apple 5
    12345 2015-02-02 Apple 3
    11223 2015-02-01 Banana 1
    11223 2015-02-01 Pear 1

    Printout in Sheet2:

    SocialSec Date Fruit Quantity
    12345 2015-02-02 Apple 8
    11223 2015-02-01 Banana 1
    11223 2015-02-01 Pear 1

    Is this possible to solve? Best way to solve it thru an array, or? Feels impossible with VBA.

    Thanks for help!

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Sum array (or something) based on multiple criteria

    Use Pivot table

  3. #3
    Registered User
    Join Date
    06-18-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Sum array (or something) based on multiple criteria

    Thanks for the tips but I need to solve it with VBA - this will be a part of my script.

    Quote Originally Posted by zbor View Post
    Use Pivot table

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Sum array (or something) based on multiple criteria

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  5. #5
    Registered User
    Join Date
    06-18-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Sum array (or something) based on multiple criteria

    TEST WORKBOOK.xlsxThank you sir.
    Will attach my workbook - sorry for the bad choice of color.

    Quote Originally Posted by zbor View Post
    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Sum array (or something) based on multiple criteria

    don't be sorry for color but for example

    Elaborate logic from:

    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.
    Is SocialSec criteria?
    is Date criteria?
    Fruit is, I got that.

  7. #7
    Registered User
    Join Date
    06-18-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Sum array (or something) based on multiple criteria

    LoL! I'm sorry for being unclear.
    Criteras: SocialSec, Date and fruit .

    Thnx in advanced!

    Quote Originally Posted by zbor View Post
    don't be sorry for color but for example

    Elaborate logic from:

    Please Login or Register  to view this content.
    to:

    Please Login or Register  to view this content.
    Is SocialSec criteria?
    is Date criteria?
    Fruit is, I got that.

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,627

    Re: Sum array (or something) based on multiple criteria

    I assume that but in that case your After sheet is wrong.
    Here, try this;

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-18-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Sum array (or something) based on multiple criteria

    Hi sir,

    My after sheet its not wrong. Its two different dates on all 3 lines of the strawberry fruit. I will try this and see how it works - will reconnect to you

    Quote Originally Posted by zbor View Post
    I assume that but in that case your After sheet is wrong.
    Here, try this;

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-18-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Sum array (or something) based on multiple criteria

    I have try to run the script but nothing happens? I placed an message box at the end and its running all the way but no printlines in sheet2? Have I forget something?
    Possible to get some comments in script? Try to read it but feels like the whole script is only based on column A wich is only 1 of 3 criteras or am I lost again?

    Quote Originally Posted by zbor View Post
    I assume that but in that case your After sheet is wrong.
    Here, try this;

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-18-2012
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Sum array (or something) based on multiple criteria

    Sir, thank you so much!!! It works perfectly!!!!! So glad!
    Possible to get som comments in the script so I can add/remove more criterias?

    thank you!

    Quote Originally Posted by zbor View Post
    I assume that but in that case your After sheet is wrong.
    Here, try this;

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Array that pulls list of data based on sum of multiple criteria
    By moses125 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-19-2015, 06:14 PM
  2. Multiply based on multiple array criteria
    By jcullen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2012, 06:14 PM
  3. Return array based on multiple criteria
    By kmacd in forum Excel General
    Replies: 3
    Last Post: 01-05-2011, 09:05 PM
  4. Replies: 4
    Last Post: 04-16-2010, 10:09 AM
  5. Using array to sum by multiple criteria including one based on prefix
    By monkdelafunk in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-29-2008, 02:24 PM

Tags for this Thread

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