+ Reply to Thread
Results 1 to 5 of 5

Adding Conditions to change the range of cells used in a countif formula

  1. #1
    Registered User
    Join Date
    08-16-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Adding Conditions to change the range of cells used in a countif formula

    Hi All,
    Any help on this issue would be great!
    Basically I have a countif formula that is counting the number of log-ins in column B that happen within set time ranges in columns D and E and is returning a value in comun F for that day of the year (01/08/2012).

    My issue is I want to copy the formula into column G for the 02/08/2012 but only want the countif formula to now look at the rows that are dated the 02/08/2012 and not the 01/08/2012 and so on as i need do it for an entire year.

    I don't think I'm explaining myself very well so I have attached an example of my worksheet so hopefully it makes it clearer what it is I am trying to do.

    Again any help would be much appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Adding Conditions to change the range of cells used in a countif formula

    Try:

    =COUNTIFS($B$3:$B$556,">="&$D3,$B$3:$B$556,"<="&$E3,$A$3:$A$556,F$1)

    copied across and down

    need to change range sizes to get the results, though
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    08-16-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Adding Conditions to change the range of cells used in a countif formula

    Quote Originally Posted by NBVC View Post
    Try:

    =COUNTIFS($B$3:$B$556,">="&$D3,$B$3:$B$556,"<="&$E3,$A$3:$A$556,F$1)

    copied across and down

    need to change range sizes to get the results, though

    Great help, thanks for that, I changed the range sizes and it works! The one other thing is that if I do a manual count on the 01/08/12 the total log-ins is 554 but the total per column F is 549 which may be something to do with my original formula.

    Do you know is there anything else I need to change?

    Thaks again.
    Last edited by tcusack; 08-22-2013 at 02:02 PM.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Adding Conditions to change the range of cells used in a countif formula

    It has to do with precision when manipulating multiple decimal numbers like time. You are using formula in D4 like =E3+TIME(0,$F$1,0) copied down... that causes inaccuracies when comparing to fixed entry time

    What I would do is insert a new column between column B and C, then in C3 enter formula:

    =ROUND(B3,6)

    copied down

    in the new G2, enter:

    =COUNTIFS($C:$C,">="&ROUND($E3,6),$C:$C,"<="&ROUND($F3,6),$A:$A,G$1)

    copied down. The sum should now be 554. Copy across. I used the Round() function to "control" the result to 6 decimals

  5. #5
    Registered User
    Join Date
    08-16-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Adding Conditions to change the range of cells used in a countif formula

    Quote Originally Posted by NBVC View Post
    It has to do with precision when manipulating multiple decimal numbers like time. You are using formula in D4 like =E3+TIME(0,$F$1,0) copied down... that causes inaccuracies when comparing to fixed entry time

    What I would do is insert a new column between column B and C, then in C3 enter formula:

    =ROUND(B3,6)

    copied down

    in the new G2, enter:

    =COUNTIFS($C:$C,">="&ROUND($E3,6),$C:$C,"<="&ROUND($F3,6),$A:$A,G$1)

    copied down. The sum should now be 554. Copy across. I used the Round() function to "control" the result to 6 decimals
    That worked perfect, 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)

Similar Threads

  1. [SOLVED] Countif a range of cells is MAX in their row(array formula)
    By Bishonen in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-04-2013, 05:19 AM
  2. Does COUNTIF work if adding non-sequential cells i.e. not a range
    By BelindaJS in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-27-2012, 11:07 AM
  3. [SOLVED] VBA Copy a range of cells values using the range of cells in a formula (which will change)
    By murtaep in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 06-05-2012, 07:59 AM
  4. Replies: 2
    Last Post: 05-31-2012, 05:37 AM
  5. Adding a simple formula to a range of cells
    By ncikusa in forum Excel General
    Replies: 2
    Last Post: 10-26-2009, 04:25 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