+ Reply to Thread
Results 1 to 6 of 6

Aggregate multiple values into one cell based on multiple criteria using VBA

  1. #1
    Registered User
    Join Date
    12-24-2012
    Location
    Boise, ID
    MS-Off Ver
    Excel 2010
    Posts
    3

    Aggregate multiple values into one cell based on multiple criteria using VBA

    I have an Excel workbook with two sheets named Summary and Data. In Data I have data broken down by Category and by Months. I need to take data broken into many categories and summarize it down into a more high level report by combining categories. I attached this in case anyone would like to view it.

    When this Workbook is opened I would like to use VBA to search the category titles found in Column A (beginning in Row 3) on the Sheet called Summary and find the data in the Data Worksheet that matches that category and total all of those entries together and place them in the correct space by Month. Hopefully that makes sense if not I am happy to clarify.

    I am stuck on using two variables AND getting the multiple values to add together in the target cell. I know I could write the code to find the values and place them in rows under the category but this time I need them added and placed according to Month.

    Thank you in advance for any help

    Monthly Data Pull.xlsm

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Aggregate multiple values into one cell based on multiple criteria using VBA

    Hi,

    Have you considered using a Pivot Table which would seem to give you exactly what you want without needing any macros. The only change you need to make is use a new column D on the Data sheet for dates, then a new Column E for the Amounts. i.e. you create a 5 column data table, the current columns A:C and the Date and Amount columns.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Aggregate multiple values into one cell based on multiple criteria using VBA

    Why not use pivot table
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-24-2012
    Location
    Boise, ID
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Aggregate multiple values into one cell based on multiple criteria using VBA

    Richard,

    In my handful of years in Excel I have never really used Pivot Tables so I had not thought about it, so I will look into it. I will let you know how it goes! Thanks to you Richard and JieJenn both!

    Best,

    J

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Aggregate multiple values into one cell based on multiple criteria using VBA

    I think you will be pleasantly surprised. If your data is in the straightforward 2 dimensional table layout I describe then they take just seconds to set up after which you can dice and slice your data just about any which way. Well worth spending an hour or so understanding them by viewing the many articles and YouTube videos on the www.

  6. #6
    Registered User
    Join Date
    12-24-2012
    Location
    Boise, ID
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Aggregate multiple values into one cell based on multiple criteria using VBA

    So that is pretty slick and amazingly easy! The only problem I am coming up against is keeping the data in a particular order. The primary reason for this task is to take data that is in one format and in many different categories and condense it down into less categories and to keep it in a very particular order to cut time and mistakes as data is entered into our database. I really like the functionality of working with a pivot table but any suggestions on how to get that data into the right order? Also it is not alphabetical, it is based off of balance sheet and income statement Assets - Liabilities - Income - Expense...

    Thanks in advance guys!

+ 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