+ Reply to Thread
Results 1 to 9 of 9

count how many cells have values between 2 defined values AND neighboring cell value is...

  1. #1
    Registered User
    Join Date
    09-28-2015
    Location
    NY
    MS-Off Ver
    14.5.2
    Posts
    4

    count how many cells have values between 2 defined values AND neighboring cell value is...

    So I have a bit of a puzzle I've been working on, and I've been bashing my head against the wall trying to get it to work properly. I'm hoping someone here can help me a little.

    Screen Shot 2015-09-28 at 12.23.06 PM.png

    I have a slew of 3-second windows (indicated in columns G and H), during which I'm have found how many times (listed column F) fit within this 3 second window. This is the first step I've needed to complete, and I've gotten it (in column I):
    =COUNTIF(F:F,">="&G3)-COUNTIF(F:F,">"&H3)

    I am trying to take this a step further. I want to see how many of those times listed in column F that occur in the 3 second window have a particular categorical value (indicated in column E). The category listed in column E indicates the type of behavior found at the time listed in column F. Ultimately, I am looking to find how many sensitive behaviors occur within the 3 second windows, and how many redirective behaviors occur within the 3 second windows independently.

    I have been trying to implement a way to indicate the cell to the left of column F in such a way that couples together the column E and F values on a particular row, and yet checks ALL rows. I've not succeeded so far.
    I've tried using indirect and address functions, but either I'm going about it the wrong way or I'm messing up the code. Can anyone help me figure out what I'm doing wrong?

    Here is my latest attempt:

    =COUNTIF(F:F,AND(F:F>=&G3,indirect(address(1:1000,6,2,,),0,-1)="sensitive"))- COUNTIF(F:F,AND(F:F>=&H3,indirect(address(1:1000,6,2,,),0,-1)="sensitive"))

    Any help is appreciated!

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    Perhaps post a sample sheet. It's easier to work with

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    I would probably use the =COUNTIFS() function rather than a combination of COUNTIF() functions: https://support.office.com/en-us/art...c-aa8c2a866842
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    09-28-2015
    Location
    NY
    MS-Off Ver
    14.5.2
    Posts
    4

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    sample data.xlsx

    Okay, here is a sample of some of the data. There is one other category in this slightly longer list (initiative), but that shouldn't change the nature of the problem. Thank you so much for looking into this!

  5. #5
    Registered User
    Join Date
    09-28-2015
    Location
    NY
    MS-Off Ver
    14.5.2
    Posts
    4

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    that is a good suggestion. I'll play around with that a little. I tried it before, but I've since come up with a few other methods that I haven't tried with that particular function

  6. #6
    Registered User
    Join Date
    01-30-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    what do you think about this. in cell I4 you could use the following formula

    =COUNTIFS(E$4:E$48,I$3,F$4:F$48,">"&G4)-COUNTIFS(E$4:E$48,I$3,F$4:F$48,">"&H4)

    From what you said, it sounded like you would like to be able to filter the results by the categories in column E but would like the results to show up in a single column (I) as opposed to having 3 separate columns displaying these results individually.

    In the attachment I've set it up so that you choose which category you want in cell I3 and the results change accordingly. You can either manually enter the category in cell I3 or create a validation list as I have done so that you can choose the category from a drop down box

    Sample Data.xlsx

    If you want the formula to only reference the category listed in the same row then use

    =COUNTIFS(E$4:E$48,E4,F$4:F$48,">"&G4)-COUNTIFS(E$4:E$48,E4,F$4:F$48,">"&H4)
    Last edited by Jonathan68; 09-28-2015 at 02:19 PM.

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    Quote Originally Posted by Jonathan68 View Post
    =COUNTIFS(E$4:E$48,I$3,F$4:F$48,">"&G4)-COUNTIFS(E$4:E$48,I$3,F$4:F$48,">"&H4)
    I would put that into a single countifs
    =COUNTIFS(E$4:E$48,E$4,F$4:F$48,">"&G4,F$4:F$48,"<="&H4)
    Last edited by Jonmo1; 09-28-2015 at 02:22 PM.

  8. #8
    Registered User
    Join Date
    01-30-2014
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    Jonmo1, you're right that is much better

    here's the sample sheet using Jonmo1's formula change
    Attached Files Attached Files
    Last edited by Jonathan68; 09-28-2015 at 02:30 PM.

  9. #9
    Registered User
    Join Date
    09-28-2015
    Location
    NY
    MS-Off Ver
    14.5.2
    Posts
    4

    Re: count how many cells have values between 2 defined values AND neighboring cell value i

    Thank you so much! I just checked over one full file and every cell was correct. You have saved me hours of searching through these files manually!

+ 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] Count Unique Values of defined cell between Two Dates
    By nickmessick1 in forum Excel General
    Replies: 4
    Last Post: 07-26-2013, 11:48 AM
  2. Replies: 3
    Last Post: 04-24-2013, 05:33 PM
  3. Replies: 1
    Last Post: 04-24-2013, 05:21 PM
  4. Sum Values If Data Exists In Neighboring Cells
    By tomcrocker in forum Excel General
    Replies: 1
    Last Post: 10-30-2012, 10:50 PM
  5. Replies: 3
    Last Post: 10-03-2012, 03:09 AM
  6. [SOLVED] Using VB code to check for negative values then subtract them from a neighboring cell
    By mick86 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-15-2012, 07:23 AM
  7. Replies: 2
    Last Post: 04-13-2010, 08:46 PM
  8. How to Count Rows with defined values in multiple columns
    By ryesworld in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-08-2005, 02:35 PM

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