+ Reply to Thread
Results 1 to 6 of 6

Count Dates in a range based on Column Header Id without using sum-product

  1. #1
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Count Dates in a range based on Column Header Id without using sum-product

    Hello All,
    I want to use the countif function to count dates in a range based on Column HEADER at the Top. For example I want to count all X005 between 01st and 10th of May, 2012.
    I am looking for a dynamic countif function using look up formula which could be replicated for other IDs like X006, X007 without highlighting the column number.
    The problem is 2-fold:
    1. Select column X005
    2. Count dates between 01st and 10th of May

    So, Once I copy over this formula in the cell below it would populates the count for X006

    I do not want to use sum-product as it takes up lot of memory and freezes excel if i try to change a date.

    The Data is shown Below: ( Actual Data runs 1000s of lines)

    ID X005 X006 X007 X008 X009 X010 X011
    A001 25-May-12 2-Jul-12 28-Sep-12 18-Jun-12 6-Jul-12 9-Sep-12 25-Aug-12
    A002 25-May-12 2-Jul-12 28-Sep-12 18-Jun-12 6-Jul-12 9-Sep-12 25-Aug-12
    A003 25-May-12 2-Jul-12 28-Sep-12 8-Jun-12 6-Jul-12 17-Sep-12 25-Aug-12
    A004 25-May-12 2-Jul-12 28-Sep-12 29-Jun-12 6-Jul-12 17-Sep-12 25-Aug-12
    A005 25-May-12 9-Jul-12 4-Oct-12 8-Jun-12 13-Jul-12 16-Sep-12 31-Aug-12
    A006 25-May-12 9-Jul-12 4-Oct-12 11-Jun-12 13-Jul-12 16-Sep-12 31-Aug-12
    A007 02-May-12 9-Jul-12 4-Oct-12 14-Jun-12 13-Jul-12 16-Sep-12 31-Aug-12

    Kindly let me know if this is possible. I appreciate all the help in this regard.

    Thanks
    Sam

  2. #2
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Count Dates in a range based on Column Header Id without using sum-product

    Hello Sam,

    Use INDEX function to determine column #. Consider data is column B:H B1:H1 is heading.

    =COUNTIFS(INDEX(B:H,0,MATCH("X006",B1:H1,0)),">="&DATE(2012,5,1),INDEX(B:H,0,MATCH("X006",B1:H1,0)),"<="&DATE(2012,5,10))

    You can replace "X006" AND date part with a cell, so whenever you enter a 'Heading' or Start & End date will update the formula.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Count Dates in a range based on Column Header Id without using sum-product

    Try this way:

    =COUNTIFS(INDEX(A:H,0,MATCH("X005",A1:H1,0)),">"&N3,INDEX(A:H,0,MATCH("X005",A1:H1,0)),"<"&N4)

    where N3 holds 1st date and N4 holds second date - also change the "X005" references to a cell address that holds that value

  4. #4
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Count Dates in a range based on Column Header Id without using sum-product

    Works like a Charm. Appreciate the Quick Response. I knew it had to something with Index function...but just could not figure it out

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Count Dates in a range based on Column Header Id without using sum-product

    We're glad to have helped. Please remember to mark your thread as SOLVED (click Forum Rules @ top of page to see instructions in rule #9).

  6. #6
    Registered User
    Join Date
    07-03-2012
    Location
    md
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Count Dates in a range based on Column Header Id without using sum-product

    Is there a way to combine the 2 criteria? Any thoughts? Thanks for the help.

+ 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