+ Reply to Thread
Results 1 to 17 of 17

Replace a list of COUNTIFS with a LOOKUP formula

  1. #1
    Registered User
    Join Date
    10-15-2020
    Location
    Scunthorpe, England
    MS-Off Ver
    365
    Posts
    20

    Smile Replace a list of COUNTIFS with a LOOKUP formula

    Hi there fellow Excel enthusiasts,

    I would be very grateful if one of you geniuses could help me simplify a formula, which will reduce errors when writing the formula as I have, and time spent putting it together. I attached a small example workbook to help understand my request.

    In the workbook there are three worksheets:

    Lists: this contains a list for data validation purposes.

    Results: this contains 6 tables of snooker match results (Week01, Week02 etc).

    Points: this collates/allocates points based on data in the Results worksheet.

    In cell E4 of the Points worksheet, I want to sum the number of times Name 04 wins a match during the 6-week season. Wins and loses (W/L) are recorded in column 9 of each of the 6 tables in the Results worksheet.

    I've generated the answer using the following formula but think there must be a better way using some form of VLOOKUP that automatically moves through the 6 tables then stops:

    =COUNTIFS(Results!$A$3:$A$60,A4,Results!$I$3:$I$60,"W")+
    COUNTIFS(Results!$K$3:$K$60,A4,Results!$S$3:$S$60,"W")+
    COUNTIFS(Results!$U$3:$U$60,A4,Results!$AC$3:$AC$60,"W")+
    COUNTIFS(Results!$AE$3:$AE$60,A4,Results!$AM$3:$AM$60,"W")+
    COUNTIFS(Results!$AO$3:$AO$60,A4,Results!$AW$3:$AW$60,"W")+
    COUNTIFS(Results!$AY$3:$AY$60,A4,Results!$BG$3:$BG$60,"W")

    This example workbook only has 6 tables in Results, but the real thing has 26 so you can see why I’m looking for a more efficient way of doing this.

    Many thank for taking the time to look at this for me
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,914

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    there must be a better way using some form of VLOOKUP that automatically moves through the 6 tables then stops:
    VLOOKUP would have to be used on each individual table in the same way as you've done with COUNTIFS, so that won't be the solution.

    So you have 26 tables - how DEEP are they? In other words, what's the maximum row depth.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    491

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Auditability might suffer dramatically by coming up with a more complex formula.
    I don't think you'll be able to simplify this really given you have to reference so many distinct tables.

    I would advise to bring your results into a better database format that makes pulling results easier.
    Is that an option, see attached?
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,914

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    I woud also recommend ONE normalised table of results with the week number as a field (column) to avoid having 26 distinct tables.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Try

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


    or

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by JohnTopley; 03-19-2024 at 02:00 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  6. #6
    Registered User
    Join Date
    10-15-2020
    Location
    Scunthorpe, England
    MS-Off Ver
    365
    Posts
    20

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Hi Ali,

    Thank you for picking this up so quickly. To answer your question, each table row has nine columns. I hope that helps.

    Bob

  7. #7
    Registered User
    Join Date
    10-15-2020
    Location
    Scunthorpe, England
    MS-Off Ver
    365
    Posts
    20

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    ...thanks again Ali - I'll have a look at your solution and get back to you

  8. #8
    Registered User
    Join Date
    10-15-2020
    Location
    Scunthorpe, England
    MS-Off Ver
    365
    Posts
    20

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Quote Originally Posted by RaulSerg View Post
    Auditability might suffer dramatically by coming up with a more complex formula.
    I don't think you'll be able to simplify this really given you have to reference so many distinct tables.

    I would advise to bring your results into a better database format that makes pulling results easier.
    Is that an option, see attached?
    Hi and thank you for getting back to me soooo quickly.

    I've had a look and what you suggest makes sense so thank you so much.

    I agree - simple is good.

    Thanks again - Bob
    Last edited by 19Batonman58; 03-19-2024 at 04:43 PM.

  9. #9
    Registered User
    Join Date
    10-15-2020
    Location
    Scunthorpe, England
    MS-Off Ver
    365
    Posts
    20

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Hi John and thank you. Unfortunately, your solutions don't seem to work as they count the number of matches (6) in which Name 04 played and not the number of matches won (4).

    Bob

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Does this work (in the example)? A bit tedious to scale up though.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Probably be easier to stack the Results tables if they were underneath one another rather than alongside.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,914

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Try this:

    =SUMPRODUCT((Results!$A$3:$AY$10=A4)*(Results!$I$3:$BG$10="W"))

    Notice the offset ranges.

    My other half hails from Scunny.

  13. #13
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    1- How are your 26 tables arranged, in rows (as in the example) or horizontally with 6 tables followed by vertical stacking?
    2- Is VBA code OK for you?
    Quang PT

  14. #14
    Registered User
    Join Date
    10-15-2020
    Location
    Scunthorpe, England
    MS-Off Ver
    365
    Posts
    20

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Quote Originally Posted by AliGW View Post
    Try this:

    =SUMPRODUCT((Results!$A$3:$AY$10=A4)*(Results!$I$3:$BG$10="W"))

    Notice the offset ranges.

    My other half hails from Scunny.
    Hi Ali,

    That works perfectly and so little to the formula. Every day's a school day.

    We are in Burton upon Stather about 5 miles north of Scunny. Settled here when I left the Army and love it here

  15. #15
    Registered User
    Join Date
    10-15-2020
    Location
    Scunthorpe, England
    MS-Off Ver
    365
    Posts
    20

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Hi and thank you for getting back to me. My tables are arranged as in the example. Yes - VBA is good for me too.
    Last edited by 19Batonman58; 03-20-2024 at 11:07 AM.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,914

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: Replace a list of COUNTIFS with a LOOKUP formula

    You're welcome. Thanks for the rep.

+ 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] VBA Code Needed to Replace Lookup Formula
    By Excell1677 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-08-2019, 03:03 PM
  2. [SOLVED] VBA to replace Countifs
    By williamsabbie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2018, 08:51 AM
  3. [SOLVED] Sumproduct to replace countifs as countifs don't work on external source reference
    By KrishnaSagar in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-02-2017, 02:33 AM
  4. replace name with id by lookup value from list
    By itmanager in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2015, 10:57 PM
  5. [SOLVED] Replace LOOKUP formula in colunms A & C, fill to last row when entry into cell in column B
    By gpato in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-30-2014, 08:10 AM
  6. LOOKUP() replace with formula in cell instead of value
    By sleepymatt in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-09-2013, 04:25 PM
  7. Create a list of the cells used in a COUNTIFS formula
    By Manial in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-10-2012, 08:30 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