+ Reply to Thread
Results 1 to 8 of 8

COUNTIF Function with Dynamic Range

  1. #1
    Registered User
    Join Date
    11-07-2012
    Location
    United Stated
    MS-Off Ver
    Excel 2007
    Posts
    20

    COUNTIF Function with Dynamic Range

    I'm attempting to use the COUNTIF formula in multiple fields of a report in a worksheet named "Cover Page". The data is in a worksheet named "Raw_Data". The issue I'm having is that the columns I'm using for the range criteria in the COUNTIF formula are never consistent. In other words, the columns in the worksheet "Raw_Data" are never in the same order. The header names are the same however. An example is where I'm counting instances 'Closed' in a column named 'Case Status':

    =COUNTIF(Raw_Data!Y:Y,"Closed")

    The formula works, but when I load the new data, chances are the 'Case Status' column will not be column Y. I considered using named ranges, but I'm not sure what formula to use for the reference (possibly the INDEX and MATCH function). I think this is the direction to go, as the formulas will be easier to manage and the ranges will dynamically change. I'm open to all suggestions.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: COUNTIF Function with Dynamic Range

    HI rzrbkpk,

    Can you upload a sample workbook to support your query. Thanks.


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    11-07-2012
    Location
    United Stated
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: COUNTIF Function with Dynamic Range

    Here is an example of the workbook I'm using. I apologize, but I had to remove a large amount of confidential data. It's still functional as far as what I'm trying to accomplish in this post. In actuality, though, the formula I would be using is COUNTIFS instead of COUNTIF since I have multiple conditions (case status and country)...I was just trying to keep it simple.
    Attached Files Attached Files

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: COUNTIF Function with Dynamic Range

    See if this helps, the Dynamic named range "Case_Status" can be in any column on Sheet "Raw_Data", (the headers must be in Row 1).

    The depth of the range is dynamic from row 2 to the last text entry in the target column.

    See the names manager to see how it is built.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Registered User
    Join Date
    11-07-2012
    Location
    United Stated
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: COUNTIF Function with Dynamic Range

    Marcol, that's perfect! It's exactly what I wanted to accomplish. Out of curiosity, why the two named ranges csCol and Case_Status? Couldn't you combine them? It looks like csCol returns the column number.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: COUNTIF Function with Dynamic Range

    You can indeed combine them, but it produces a longer formula that is harder to read and understand.

    You are bang on "csCol" returns the target column number.

    I'm fairly sure it makes no difference to the efficiency whatever way you go.

    Happy to have helped...

  7. #7
    Registered User
    Join Date
    05-31-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: COUNTIF Function with Dynamic Range

    hello everyone i m new for this forum, so dont know how to make a new post

    I have a problem in function countif
    actually i want to use countif function which change itself after change in a cell reference
    but my problem is that i want to get exact match
    for example if cell refrence has value "RAJ" , then it gives many count which has RAJ and I want to know the exact match for RAJ

    please help me guys

  8. #8
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: COUNTIF Function with Dynamic Range

    HI Shantanu,

    Welcome to the forum.
    Please start your own thread rather then posting your query in other user's thread. Thanks.

    Regards,
    DILIPandey
    <click on below * if this helps>

+ 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