+ Reply to Thread
Results 1 to 7 of 7

Matching multiple columns, summing multiple results

  1. #1
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58

    Matching multiple columns, summing multiple results

    Hi guys, I was wondering if you have some idea on how to do this. I have been trying with formulas, but not getting very far, so am hoping there is a way of doing this with macros. I am presently learning about macros (very slowly), so any helpful hints in the code, or even just a general shove in the right direction for me to figure it out myself would be most appreciated

    I am trying to compare various columns on the same row on one sheet, to various columns on all the rows on another sheet, and to add up the numbers in column M when there is a match.



    Match 1:
    If the value in F1 appears in Sheet 2, column F
    Then add up numbers in Sheet 2, column M on the corresponding rows
    SUMIF(Sheet2!F:F,F1,Sheet2!M:M)


    Match 2:
    If the value in D1 appears in Sheet 2, column A and the value in E1 appears in Sheet 2, column B on the same row, then add up numbers in Sheet 2, column M on corresponding rows.
    I’m having trouble with that one, because with VLookup it will only return the first value. I thought about letting it return multiple values and then comparing the results with cell E1, but I only have one row per entry, and for multiple values I would need blanks rows directly below.

    Odd addition if possible:
    Match 2, plus the first word in G1 compared to the first word in Sheet2, Column H on the same row.

    Overall:
    If the sum of numbers from column M does not exceed 25, delete the row. If it does, show the sum.
    I know this last one needs a macro rather than a formula anyway. As I use the IF function a lot in formulas, I am especially keen to get the hang of this one in macro form.

    Would anybody be able to help with this? Any assistance would be most appreciated.

  2. #2
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    macro

    Hi
    pl post a sample workbook with expected results
    Ravi

  3. #3
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    d e f

    Smith John A123
    Mulcahy John B789
    Smith Peter C258
    Johnstone Patricia A197






    a b f m

    Star Fred T458 21
    Smith Simon A123 2
    Bailey Bill B759 5
    Johnstone Patricia A198 14
    McGrath William T748 2
    Fox Anthony Y753 9
    Bucket Clare X458 6
    Johnstone Patricia A199 12
    Smith Simon A123 3




    Match 1:

    The value in F1 on sheet 1 matches the value in F2 and F9 on sheet 2. So in A1 on sheet 1 I would like to have the sum of the values in column M matching those two entries (5).


    Match 2:

    D4 and E4 on sheet 1 also appear in A4/B4 and A8/B8 on sheet 2. So I would like to have the sum in column M again (26).


    I have now been busy combining the first and last names, so I can now turn column D/E on sheet 1 and column A/B on sheet two into one column, which should make matters easier.


    Overall:

    Deleting any row where the value in column A is less than 25 should just leave Patricia Johnstone, with the value 26 in column A.
    Last edited by DamienC; 07-08-2008 at 09:35 AM.

  4. #4
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    Sorry, that doesn't quite appear the way I tried to make it appear, with lots of room in between entries and the words underneath the column letter.

  5. #5
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    I have now fixed this using a formula and a macro I found in another thread on the site. Many thanks!

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by DamienC
    I have now fixed this using a formula and a macro I found in another thread on the site. Many thanks!
    Can you kindly post a link to that thread so that it may help others in the future who come across your thread with a similar question?

    Thanks.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  7. #7
    Registered User
    Join Date
    07-03-2008
    Location
    Scotland
    Posts
    58
    Should have thought of that myself.

    It was to do with the overall result and removing lines. Took the macro posted by royUK:

    Please Login or Register  to view this content.


    and changed it to:




    Please Login or Register  to view this content.

    I switched off the auto calculation to prevent it from recalculating after deleting every single row.
    Last edited by NBVC; 07-09-2008 at 09:39 AM.

+ 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