+ Reply to Thread
Results 1 to 10 of 10

Reduce Multiple COUNTIFs

  1. #1
    Forum Contributor
    Join Date
    04-22-2017
    Location
    AU
    MS-Off Ver
    Microsoft 365
    Posts
    291

    Reduce Multiple COUNTIFs

    Hello all

    Does anyone have a way to reduce the multiple COUNTIF function in the following to use one COUNTIF to encompass all ranges please?

    =COUNTIF('Panel Draw'!B11:T40,"H1")+COUNTIF('Panel Draw'!B58:T87,"H1")+COUNTIF('Panel Draw'!B105:T134,"H1")+COUNTIF('Panel Draw'!B145:T174,"H1")+COUNTIF('Panel Draw'!B185:T223,"H1")

    I need to use the statement addressing different cell ranges about 200 times in a Workbook.

    Tanks

  2. #2
    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,137

    Re: Reduce Multiple COUNTIFs

    Will ther be any instances of H1 in between the specified ranges? If not, why not use:

    =COUNTIF('Panel Draw'!B11:T223,"H1"), or even:

    =COUNTIF('Panel Draw'!B:T,"H1")
    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

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,608

    Re: Reduce Multiple COUNTIFs

    Try this

    =SUMPRODUCT(COUNTIF(OFFSET(B12:T41,(ROW($1:$3)-1)*47,0),"H1"))+SUMPRODUCT(COUNTIF(OFFSET(B146:T175,(ROW($1:$2)-1)*40,0),"H1"))
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Forum Contributor
    Join Date
    04-22-2017
    Location
    AU
    MS-Off Ver
    Microsoft 365
    Posts
    291

    Re: Reduce Multiple COUNTIFs

    Thanks Glenn

    Yes there are several instances of the Hi in between the ranges, and not to be included in this statement. hence the specific ranges.
    When I used your suggestion, HI was being included in calculations even though Hi was outside the specified range.
    I also tried the Sum(Product) statement, and the sum(countif) but still very long.
    Have not tried yet but I wonder if a named range would shorten the statement?

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,608

    Re: Reduce Multiple COUNTIFs

    Try this, This works.

    =SUMPRODUCT(COUNTIF(OFFSET('Panel Draw'!B11:T40,{0,47,94,134},0),"H1"))+COUNTIF('Panel Draw'!B185:T223,"H1")
    Last edited by kvsrinivasamurthy; 01-04-2018 at 08:54 AM.

  6. #6
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,414

    Re: Reduce Multiple COUNTIFs

    Why do you want to reduce the length of the formula? What is your perceived problem with it? Is it to do with the formula's performance, or merely an aesthetic whim? If the latter, then if it ain't broke, you don't need to fix it.
    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.

  7. #7
    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,137

    Re: Reduce Multiple COUNTIFs

    The solution at post 5 only works if the ranges are all the same size. they aren't.

    here's another option that will work with irregularly sized blocks.

    I have used "my own" ranges for ease of demonstration:

    =SUM(COUNTIF(INDIRECT({"A1:B5","A12:B16","A19:B27"}),"H1"))

    or, using named ranges:

    =SUM(COUNTIF(INDIRECT({"rnga","rngb","rngc"}),"H1"))
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    04-22-2017
    Location
    AU
    MS-Off Ver
    Microsoft 365
    Posts
    291

    Re: Reduce Multiple COUNTIFs

    Thank you Glenn. Your Indirect part ensures I only count data within the range and does shorten the whole formula.
    I was getting calculations including data outside the cell ranges (such as headings and cell addresses containing H111 etc.)
    Attached is an example of my workbook which is designed to gather data on Football players.
    I want to place the formulas in a separate tab which I can password and hide.

    The part I have not been able to figure out is how to include the Panel Draw Tab name in the formula. Have tried many variations but no success.
    This link is indicating a 3rd Reference is not allowed. If this is the case, is there another solution please?
    https://www.pcreview.co.uk/threads/s...heets.3770785/
    Attached Files Attached Files

  9. #9
    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,137

    Re: Reduce Multiple COUNTIFs

    see amendments. However.... if the only reason that you are splitting the dataset is to make it look pretty when you print it - it can be done MUCH more simply. So, why do you have 3 separate sections?
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    04-22-2017
    Location
    AU
    MS-Off Ver
    Microsoft 365
    Posts
    291

    Re: Reduce Multiple COUNTIFs

    Thankyou Glenn. I am a novice with EXCEL so appreciate your amendments - I would never achieved that formula.

+ 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. Reduce file size of multiple images with excel VBA
    By motmot11 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2021, 10:02 PM
  2. [SOLVED] How to reduce multiple IF functions in formula
    By Regina HR in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 09-18-2014, 07:17 AM
  3. Reduce time in processing multiple excel sheets
    By rexer231 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-07-2014, 06:00 AM
  4. Replies: 1
    Last Post: 12-17-2013, 03:18 PM
  5. COUNTIFS OR...multiple countifs without duplication in the numbers
    By HooligaD in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-21-2012, 09:53 AM
  6. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  7. Delete multiple rows to reduce size of large spreadsheet
    By The Geologist in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2011, 01:54 PM

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