+ Reply to Thread
Results 1 to 8 of 8

Countifs, Boolean <= & >=, Text or Value

  1. #1
    Forum Contributor
    Join Date
    02-27-2004
    Location
    California, United States
    MS-Off Ver
    Excel 2016
    Posts
    315

    Countifs, Boolean <= & >=, Text or Value

    I am looking for assistance to figure out why my formula is not working to parse out data from a column. My formula is:

    =COUNTIFS(E$3:E$26,">="&LEFT(B3,4),E$3:E$26,"<="&RIGHT(B3,4))

    Column B contains a list of 24 hour time frames (i.e. 0000 to 0100)
    Column E contains a data list of 24 hour times (i.e. 0500, 0130, 1000, etc.)

    I am trying to count the number of times a value occurs in column E within the range that is in column B. If I take out the > or < signs and just leave the = sign, a version of the formula for a specific number will work but I need it to search for a range and not a specific value.

    I have attached a simplified version of my workbook (which in itself contains several tabs and hundreds of rows of data on various tabs)

    Thank you in advance!!!!

    Cliff Watson
    Attached Files Attached Files

  2. #2
    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: Countifs, Boolean <= & >=, Text or Value

    There's a gap on your ranges; 0000 doesn't belong to any time band.
    Attached Files Attached Files
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Countifs, Boolean <= & >=, Text or Value

    I think you are mixing numbers and texts... ">=" requires a number, not text... maybe use =VALUE(LEFT(B3,4))

  4. #4
    Forum Contributor
    Join Date
    02-27-2004
    Location
    California, United States
    MS-Off Ver
    Excel 2016
    Posts
    315

    Re: Countifs, Boolean <= & >=, Text or Value

    shg - my mistake... my first line in the sheet as you can see is actually 0001 to 0100. Looking at the scratch.xlsx file you uploaded, you changed the data type in column E so it isn't text anymore. I need to keep the data type as text because that is how it is imported from Access (copy/paste actually). When I use the IsText() function on the data, I get a true. Once I change the data type to what you set (I actually did a copy/paste of your column E to mine and then my formula worked).

    djapigo - I have stuck in the function to change the text to a value when taking the time out of column B but when I use the value function to change the text of the data, I get an Excel formula error. I have tried just using the value function when pulling the time out of column B and that didn't work.

    It seems the key to this problem is the data type for the actual data that I take from the Access database.

  5. #5
    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: Countifs, Boolean <= & >=, Text or Value

    The gap still exists. The last band should be 2301 to 2400 for consistency.

    =SUMPRODUCT((E$3:E$26 >= LEFT(B3,4)) * (E$3:E$26 <= RIGHT(B3,4)))

  6. #6
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Countifs, Boolean <= & >=, Text or Value

    **** ignore **** shg has a really elegant solution above without the need of the array-enter

    Hi Cliff,

    Try this array-formula...

    =SUM((VALUE($E$3:$E$26)>=--LEFT(B3,4))*(VALUE($E$3:$E$26)<=--RIGHT(B3,4)))

    You must use array-enter (CTRL-SHIFT-ENTER), not just ENTER (you will see magical curly brackets {formula})

    This seems to work with your original texts... I kind of combined shg's solution with the old version of array-formulas...

    Let me know if this does not work...

    Dennis

  7. #7
    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: Countifs, Boolean <= & >=, Text or Value

    Not so elegant, methinks. I'd expect the countifs to work as originally written, but didn't want to take the time to figure it out.

  8. #8
    Forum Contributor
    Join Date
    02-27-2004
    Location
    California, United States
    MS-Off Ver
    Excel 2016
    Posts
    315

    Re: Countifs, Boolean <= & >=, Text or Value

    Both of these solutions work awesomely!

    Thank you very much. I need to get to know the sumproduct function better!

    Thank you again!!!

    Cliff Watson

+ 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. Replies: 2
    Last Post: 02-20-2012, 05:59 PM
  2. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  3. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) problem
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2009, 07:28 PM
  4. Function to return boolean if activeworkbook name has specific text
    By ctmurray in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-13-2008, 04:11 PM
  5. Comparing text and returning boolean values
    By nicoleeee in forum Excel General
    Replies: 9
    Last Post: 12-02-2005, 06:43 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