+ Reply to Thread
Results 1 to 34 of 34

Combine VLOOKUP and SUMIFS

  1. #1
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Combine VLOOKUP and SUMIFS

    Please see attached
    Input Data : Col A to Col F
    Output data : Col G : Col K

    I have created a SumIF formula that calculates the goals for and goals against the team.
    However I want to amend is so that is will match the name against column H and populate the relevant data.

    For example.
    If Team name = ABC then it does a vlookup (col A to Col F) and match the name against Row I4 then
    Under Col I and H: uses the SUM IF formula to show the correct data.


    I tried using the under cell I3 but it returns #VALUE!

    =SUMPRODUCT(--(B:B=H3),SUMIF(C:C,$D$2,D:D)+SUMIF(C:C,$E$2,E:E))



    A formula to show the below correct data.
    Name For Against
    ABC 10 5 5
    XYZ 8 5 3
    Attached Files Attached Files

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Combine VLOOKUP and SUMIFS

    Into I3:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and down.

    Drag it right and swap last argument (D2 with E2) like (into J3):
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and down.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Forum Contributor jomaor1's Avatar
    Join Date
    10-08-2018
    Location
    Brasil
    MS-Off Ver
    Excel 2016
    Posts
    177

    Re: Combine VLOOKUP and SUMIFS

    Hi,

    you just had to change from SUMIF to SUMIFS

    Cheers!
    Attached Files Attached Files
    John.

    "I excel at jumping to conclusions"

  4. #4
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    Thank you for the prompt response.

    The data will be added as more games are played.

    I would like to create a formula/macro that will automatically populate the data of the individual names on the next available row.(under the correct worksheet)

    therefore Name = Worksheet as per below.

    Sheetname : ABC
    DATE NAME TEAM Red Black status
    06/11/2019 ABC RED 5 2 W
    07/11/2019 ABC BLACK 3 5 W

    Sheetname : XYZ
    DATE NAME TEAM Red Black status
    10/11/2019 XYZ RED 2 4 L
    10/11/2019 XYZ BLACK 1 6 W


    Is there an easy way to do this!

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Please post a sample sheet showing WHAT you want to see, WHERE you want to see it, AND populate it with some manually calculated expected results.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Please amend your profile to give an indication of your geographical location. "UG" may mean Uganda, or....???

    Many answers rely on a rough knowledge of where you are.

  7. #7
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    Worksheet DATADUMP contains a list of all the data. This sheet will be updated on a regular basis.


    OUTPUT SHEETS: A,B,C,D


    If Name = A under DATADUMP sheet then all information will be copied to worksheet A
    If Name = B under DATADUMP sheet then all information will be copied to worksheet B
    If Name = C under DATADUMP sheet then all information will be copied to worksheet C
    If Name = D under DATADUMP sheet then all information will be copied to worksheet D

    Any new data entered under the input sheet will automatically be copied to the relevant Output worksheet at the next available row.

    Please see attached. Hope this help!
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Use this in A2, copied across and down:
    =IFERROR(INDEX(datadump!A:A,AGGREGATE(15,6,ROW(datadump!$A$2:$A$20)/(datadump!$B$2:$B$20="A"),ROWS(A$2:A2))),"")

    Change formats from date to General, as appropriate. If you want to hide the zeros in column E, amend that formula to

    =IFERROR(1/(1/INDEX(datadump!E:E,AGGREGATE(15,6,ROW(datadump!$A$2:$A$20)/(datadump!$B$2:$B$20="A"),ROWS(E$2:E2)))),"")

    Done for A, do similarly for the other sheets.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    thank you. It worked.

    How to I add it so it picks up wildcards - for example if name = "A" or name = "A 123" or name = "A Extra" then it will be displayed under worksheet A

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Is "A" ALWAYS a single character?

    Is "A" ALWAYS at the start of the string? If YES to both, then:

    =IFERROR(INDEX(datadump!A:A,AGGREGATE(15,6,ROW(datadump!$A$2:$A$20)/(LEFT(datadump!$B$2:$B$20,1)="A"),ROWS(A$2:A2))),"")

    If not, please supply a really representative list.

  11. #11
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    Noted, Real list as follows:

    If suffix is a number or "Extra" or "Test" then add to the same sheet as name. (more suffix words can be added later but will not coincide with surname eg adam smith with be another worksheet as per below)

    NAME: ADAM, BOB, CATHERINE, DAVID, ADAM SMITH , ADAM EXTRA, ADAM SMITH 543, CATHERINE TEST ,DAVID EXTRA, ADAM 123 & AADAM

    Worksheet ADAM to show ADAM & ADAM EXTRA & ADAM 123
    Worksheet ADAM SMITH to show ADAM SMITH & ADAM SMITH 543
    Worksheet AADAM to show AADAM

    Worksheet BOB to show BOB
    Worksheet CATHERINE to show CATHERINE & CATHERINE TEST
    Worksheet DAVID to show DAVID & DAVID EXTRA

    Hope that clarifies.

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Mmmm. Having an "Adam" and an "Adam Smith" might be a pain. Can't you assign something to them to make them unique? The point being that the first four letters of Adam are also the first four of Adam Smith....

  13. #13
    Valued Forum Contributor
    Join Date
    05-11-2013
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    586

    Re: Combine VLOOKUP and SUMIFS

    Hi Kenrub1,

    Or you could do it using a Pivot Table - see attached.

    No formulas or Macros.

    Regards

    peterrc
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    If I place and underscore or a dot therefore adam_smith or adam.smith can the formula work?
    Alternatively I can split it and have two columns - first name and surname?

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    adam_smith or adam.smith will be fine. I will post again shortly.

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    OK. use variants of this:

    IFERROR(INDEX(datadump!A:A,AGGREGATE(15,6,ROW(datadump!$A$2:$A$20)/(ISNUMBER(SEARCH($A$1,datadump!$B$2:$B$20))),ROWS(A$3:A3))),"")
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    any updates?

  18. #18
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Yes. Read my last post!!??

  19. #19
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    sorry - totally missed that.
    I will have a look. Thank you. Much appreciated.

  20. #20
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    Thanks. It works like a charm!

    I have one final request. See attached K5:L8
    1. Show total games played where name = cell (A1)
    2. Display the status of the last three games.

    This formula does not work =INDEX(F:F,INDEX(MAX(($F:$F<>"")*(ROW(F:F))),0))

    Requirements:
    1. If status is blank then go to the next cell up.
    2. If name is not equal to cell A1 then go to the next cell up.
    Attached Files Attached Files

  21. #21
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Do you REALLY have 1,000,000 rows of data? If not you need to be careful about which formulae you use whole column references with. Otherwise your sheet will get very slow!! I will look at your query shortly.

  22. #22
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    Datadump sheet will be atleast 1000 rows of data.
    Sheet with name (adam.smith) will be atleast 200 rows
    Total number of sheets approx 20 sheets which contain the formulas
    I will then add more sheets and macros to complete the workbook.

  23. #23
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    datadump, F10 to I10 all contain a space. Are these present in your REAL data, or is this a mistake?

  24. #24
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    This is correct!

    If I do not have a space then the data is populated as below.
    DATE NAME TEAM DR CREDIT status goals Red Black
    12/11/2019 Adam.Smith 00/01/1900 0 500 00/01/1900 0 0 0

    Required as per file:
    DATE NAME TEAM DR CREDIT status goals Red Black
    12/11/2019 Adam.Smith 500


    If formula can we amended to not display if cell is empty or blank then I will not need the space.

  25. #25
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Kill the spaces. Otherwise they will mess you up later on!

    In F3:

    =IFERROR(INDEX(datadump!F:F,AGGREGATE(15,6,ROW(datadump!$A$2:$A$20)/(ISNUMBER(SEARCH($A$1,datadump!$B$2:$B$20))),ROWS(F$3:F3)))&"","")

    In L3:
    =SUMPRODUCT(($B$3:$B$21=A1)*(--(LEN($F$3:$F$21)>0)))

    In L4, copied down:
    =INDEX(F:F,AGGREGATE(14,6,ROW($F$3:$F$21)/(($B$3:$B$21=$A$1)*($F$3:$F$21<>"")),ROWS(L$6:L6)))

    Dio not use whole column references. If you reckon 2000 rows, change ranges to 4000 rows. That will be future-proof. Where I have used whole-column references, leave them as they are.
    Attached Files Attached Files

  26. #26
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    ok thank you.


    If there is no values, then this formula shows #NUM!

    =INDEX(F:F,AGGREGATE(14,6,ROW($F$3:$F$21)/(($B$3:$B$21=$A$1)*($F$3:$F$21<>"")),ROWS(L$6:L6)))

  27. #27
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    If there is no value.... where???

  28. #28
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    If the sheet has no data, for example sheet called BOB, then the last game returns #NUM!
    If Sheet contains only one row then then the second last and third last game returns #NUM!
    etc
    Attached Files Attached Files

  29. #29
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Just wrap it in an IFERROR:

    =IFERROR(formula,"")

    so:

    =IFERROR(INDEX(F:F,AGGREGATE(14,6,ROW($F$3:$F$21)/(($B$3:$B$21=$A$1)*($F$3:$F$21<>"")),ROWS(L$6:L6))),"")

  30. #30
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    thanks. One final request.
    I want to create a dynamic range.
    The below formula creates the range for all with the formula. I only want range with data (no blank cells with formulas).

    For example under Adam.Smith I have copied formulas from A2:I20 but the data only is from A2:15 then the range should only be from A2:I5 (which will dynamically change as more data is entered)

    Sub Range()
    Dim myrange As String
    myrange = Cells(Rows.Count, 9).End(xlUp).Address
    ActiveSheet.PageSetup.PrintArea = "$A$1:" & myrange
    End Sub

  31. #31
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Why not just use formulae?

    NR called Range

    Range:
    =datadump!$B$2:INDEX(datadump!$B$1:$B$1000,SUMPRODUCT(--(LEN(datadump!$B$1:$B$1000)>0)))

    Formulae now look like:
    =IFERROR(INDEX(datadump!A:A,AGGREGATE(15,6,ROW(Range)/(ISNUMBER(SEARCH($A$1,Range))),ROWS(A$3:A3))),"")

    I see that I have forgotten to correct your use of whole column references with SUMPRODUCT. Don't. Very slow. It makes 1,000,000 calculations, twice, in the execution of that formula. I therefore created two more NRs on Adam.Smith (Name & Status), with the same sort of formula. The formulae in L5-L8 now look only as far down the Adam.Smith table as needed.

    If you want to create new tables, as required using right click/move or copy/"Adam.smith"/create a copy and then rename the sheet, the 2 NRs will update with the new sheetname.

    But... save processing power, why not use a DD box in Cell A1???, powered by a list of unique player names???
    Attached Files Attached Files

  32. #32
    Registered User
    Join Date
    03-22-2019
    Location
    KENYA
    MS-Off Ver
    2010
    Posts
    21

    Re: Combine VLOOKUP and SUMIFS

    I think there is a misunderstanding.
    What I want to to create a dynamic range. Therefore when I print the worksheet, I will only print the rows where there is data.
    Currently when I print, it still prints all the other rows where we have put in in the formula.

    Adam.Smith should only print from A1:I4 (this range keeps changing as we add more data)

  33. #33
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    You did not mention the word "Print" before now. I'm not a mind-reader!!

  34. #34
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,004

    Re: Combine VLOOKUP and SUMIFS

    Do you want to print Columns A to L or just A to I???

+ 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. Attempting to combine a sumifs for specific text and date
    By wetgoose69 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-03-2019, 10:09 AM
  2. [SOLVED] How to combine multiple sumifs without using +
    By nir2500 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-25-2019, 04:38 AM
  3. How to mix vlookup with sumifs?
    By Weaselwithagun in forum Excel General
    Replies: 5
    Last Post: 02-11-2018, 11:44 AM
  4. [SOLVED] Combine SUMIFS and INDEX MATCH - or an alternative that achieves the same...
    By STUARTXL in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-17-2016, 01:06 PM
  5. Sumifs Using Vlookup
    By mtndewgradon in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-30-2014, 05:30 PM
  6. How to combine Subtotal, Sumifs and more
    By Tipler93 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-23-2014, 12:12 PM
  7. SUMIFS and VLOOKUP
    By Faustocruz in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-06-2014, 03:36 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