+ Reply to Thread
Results 1 to 11 of 11

Sum 2 columns on Matching values.

  1. #1
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Sum 2 columns on Matching values.

    I'm trying to extend the code below by MickG, jindon contributed to this too, but I can extend his code.

    https://www.excelforum.com/excel-pro...e-columns.html

    Why is it I cannot do this:

    Dic(Ray(n, 4))(Ray(n, 2))(Ray(n, 2)) = Ray(n, 1) = Ray(n, 1)

    with this line:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Xrull; 07-02-2019 at 02:57 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Sum 2 columns on Matching values.

    you do using msgbox
    Please Login or Register  to view this content.
    "ThankyouFor Attention * And Your Help!!"

  3. #3
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Re: Sum 2 columns on Matching values.

    daboho,

    Thanks for the response.

    I was trying to adapt the code to work on the spreadsheet I attached. See the code below:

    I was wondering if I can adjust line 110 to something like the line below to work.

    Please Login or Register  to view this content.
    if Column A and B are unique, the amounts in Columns E and F will accumulate or be summed.

    Please Login or Register  to view this content.
    Thanks

  4. #4
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Sum 2 columns on Matching values.

    I am sorri i am not see your workbook
    But if only col a and col b is unique
    You can join col a & col b become one key
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Sum 2 columns on Matching values.

    If mother and child dictionary
    Please Login or Register  to view this content.
    Last edited by daboho; 07-04-2019 at 12:08 AM.

  6. #6
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Re: Sum 2 columns on Matching values.

    Daboho,

    Thank your for responding. The codeworked but I also need to accumulate column E, so I adjusted the code to the one below, and it worked perfectly.

    Please Login or Register  to view this content.
    I'm improving my knowledge on dictionaries, arrays (jagged arrays); can you explain the line below to me? Jindon gave me a little tutorial a few weeks ago, but I'd appreciate your input. I'll close the thread soon.
    Please Login or Register  to view this content.
    Regards,
    Xrull

  7. #7
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Sum 2 columns on Matching values.

    Or you can exstract mother and child key like this
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Re: Sum 2 columns on Matching values.

    daboho,

    I understand it a little better now.

    When I grow up I want to be like you jindon, and MickG.

    Regards,
    Xrull

  9. #9
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Sum 2 columns on Matching values.

    If you want know mother and child dictionary
    A B
    1 2
    1 3
    1 4
    2 11
    2 9
    First filter col a with criteria 1
    You will be see
    1 2
    1 3
    1 4
    Ok dictionary only can save unique key
    Than
    1 >> 2,3,4
    Key for mother= 1 and key for child = 2,3,4
    Dim mother as object,child as object
    Set mother = dic(x(i,1))
    So become
    Please Login or Register  to view this content.
    Key for dic(1) is x(i,2))
    And item for mother and child= empty

  10. #10
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Re: Sum 2 columns on Matching values.

    daboho,

    This line is jamming up in the first example.

    Please Login or Register  to view this content.
    and if possible, I'd appreciate a file with the second example.

    Regards,
    Xrull

  11. #11
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,256

    Re: Sum 2 columns on Matching values.

    your problem enaugh with one key
    but if you want to know mother and child
    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. [SOLVED] Matching values in two columns, then comparing values in adjacent cells
    By crfcaio in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-03-2017, 07:40 PM
  2. [SOLVED] MIN and MAX matching values in 2 columns
    By drgkt in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-27-2017, 09:04 PM
  3. matching same values in two columns
    By apaul8co in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-31-2013, 10:07 AM
  4. matching values based on criteria and return values from another columns
    By lizard54 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2012, 11:29 AM
  5. [SOLVED] Matching when values are in several possible columns
    By mgreg in forum Excel General
    Replies: 6
    Last Post: 06-13-2012, 11:10 AM
  6. Matching Values from different columns
    By T De Villiers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-13-2006, 02:28 PM
  7. [SOLVED] Matching values in 2 columns
    By Aonghus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-09-2005, 11:35 AM

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