+ Reply to Thread
Results 1 to 4 of 4

Adding Row Values depending on Corresponding Rows

  1. #1
    Registered User
    Join Date
    06-13-2007
    Posts
    2

    Adding Row Values depending on Corresponding Rows

    To best explain my problem I will use this example

    Dog 2 400
    Cat 4 300
    Car 1 200
    Dog 7 800
    Car 8 900

    That data is in the top of my worksheet, and I would like to be able to find all the dog values then reference the 2nd and 3rd column and add all the dog values up and then post the totals in a area below like this

    dog 9 1200
    cat 4 300
    car 9 1100

    Stipulations
    1) there are different amounts of values, there may be 1 dog value or 10 dog values, I would like the program to recognize the dog values and add the corresponding values.
    2) dog, cat, car values are not the only values, there may be others like "tree, apple" but are not in use. So only values in the top of the spreadsheet get referenced to the bottom part.
    3) New values can be added in other spreadsheets, so the program would recognize only the VALUES in use.
    4) Since the amount of data can change from spreadsheet to spreadsheet, I have been using relative references, so the data in the second part of the sheet would be

    offset(x,y)

    from a specified cell.


    This can be done manually could use pivot table, but I am trying to automate a spreadsheet, and am coding it in VBA, I've been working on this problem for a few days with no luck on this particluar problem.

    If anybody can help me I would greatly appreciate it, If you can't help but at least can reference me to any documentation on this problem, I would also greatly appreciate that as well.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Have you considered using the SUMIF worksheet function? This can also be used in a macro if preceeded by the Application object.

  3. #3
    Registered User
    Join Date
    06-13-2007
    Posts
    2
    thats also a possibility and so is pivot table, but the cells where the =sumif would go would be relative to the other cells and amount of data in the top part take for example

    Please Login or Register  to view this content.
    In another worksheet the range may start from B50 or B60, what i have been using is a macro to find the first blank row and offsetting like this
    Please Login or Register  to view this content.
    what you had in mind was
    Please Login or Register  to view this content.
    this would not work because the relative offsets you be different depending on where the last cell for the offset would be located

    I have tried to do an array, collection, object, but am not getting anywhere with this

    Can anyone provide any assistance
    Last edited by VBA Noob; 06-13-2007 at 04:00 PM.

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Slightly confused, can you post a copy of a spreadsheet with a couple of examples containing different amounts of data and what you expect from the formula and where it should appear?

+ 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