+ Reply to Thread
Results 1 to 10 of 10

Setting a limit on a countif function

  1. #1
    Registered User
    Join Date
    06-08-2012
    Location
    Owenton, KY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Setting a limit on a countif function

    I want an error message to pop up once my COUNTIF function reaches a count over 30. Here is my function =COUNTIF(G:G, "10:30:00 AM"). Once there are 31 "10:30" values in column G I want the error message to appear. I've tried a few things in Data Validation but am not quite sure what I need to do.


    Any help would be great

    Thanks,
    Matt

  2. #2
    Forum Contributor
    Join Date
    06-23-2010
    Location
    Iowa, United States
    MS-Off Ver
    Excel 2007
    Posts
    145

    Re: Setting a limit on a countif function

    Try:

    IF(COUNTIF(G:G, "10:30:00 AM")>30,Error,COUNTIF(G:G, "10:30:00 AM"))

    Let me know if this works.

    Steve
    A VBA novice, excited to learn!

  3. #3
    Forum Contributor
    Join Date
    06-23-2010
    Location
    Iowa, United States
    MS-Off Ver
    Excel 2007
    Posts
    145

    Re: Setting a limit on a countif function

    IF(COUNTIF(G:G, "10:30:00 AM")>30,"ERROR",COUNTIF(G:G, "10:30:00 AM"))

    Sorry, bad syntax on the previous formula.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Setting a limit on a countif function

    ok, "30" is not the same as 10:"30". 10:30 is just the format the mumber os displayed as. its actual value is 0.4375, and 10:30 is actually 0.438194444444444.

    So if you want to restrict your count to 10:30 (which im guessing is not the ONLY number you want it to check for), you need to resstrict it to <0.438194444444444

    not sure of the exact format, but it needs to include a test for =MINUTE(10:30)+0
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    06-08-2012
    Location
    Owenton, KY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Setting a limit on a countif function

    Steve,

    That's closer to what I was wanting. It switches from 30 to error if another 10:30 value is added but I was hoping for some sort of pop up dialog box so it would stop the person from entering more values.

  6. #6
    Forum Contributor
    Join Date
    06-23-2010
    Location
    Iowa, United States
    MS-Off Ver
    Excel 2007
    Posts
    145

    Re: Setting a limit on a countif function

    Ok, in that case I am nearly certain that you will have to use VBA. Creating a Message Box with VBA is simple, but I am not sure how to have it constantly checking if there are more than 30 "10:30"s. Perhaps someone else can help with this.

    Steve

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

    Re: Setting a limit on a countif function

    You can use Data Validation for the cells in column G. Use this formula after selecting Custom: =COUNTIF(G:G,0.4375)<31
    Then set up your error message on the Error Alert tab. You can also use an input message as an option.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Setting a limit on a countif function

    Or =COUNTIF(G:G, "10:30")<31
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    06-08-2012
    Location
    Owenton, KY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Setting a limit on a countif function

    That worked! Thank You. Now is there anyway to expand on this to include a limit on multiple values such as =countif(G:G, "10:30, 11:00, 11:30, 2:00, 2:30, 3:00")<31. Would this work to make sure each value wouldn't exceed 30?

  10. #10
    Registered User
    Join Date
    06-08-2012
    Location
    Owenton, KY
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Setting a limit on a countif function

    To be more clear I have about 300 rows of data and in column G, you can input time slots 10:30, 11:00. 11:30, 2:00, 2:30, or 3:00. If any individual value exceeds 30 in the column, not over 30 total inputs, I want an error message to pop up.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Setting a limit on a countif function

    =COUNTIF(G:G, myCellAddress)<31

+ 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