+ Reply to Thread
Results 1 to 7 of 7

count how many times we have the same value in two (or more) adjacent cells

  1. #1
    Registered User
    Join Date
    03-27-2012
    Location
    Sofia
    MS-Off Ver
    Excel 2010
    Posts
    46

    count how many times we have the same value in two (or more) adjacent cells

    Guys,

    I am trying to figure out a way to calculate the Bradford factor - https://en.wikipedia.org/wiki/Bradford_Factor.
    It's =the total number of spells/instances/occurrences of absence squared, multiplied by the total number of days of absence.
    And for this, I need to come up with a way to count the occurrences of a certain data (in my case - SL's) in adjacent cells (the sum of the absent days is a simple sumif or countif).
    To clarify:

    Basically in this example we have a total of 7 SL (Sick Leave) days in 2 occurrences.
    screen1.JPG

    So I am scratching my head trying to figure out how I can calculate the "occurrences", e.g. how many times we have the "SL" occurring in 2 or more adjacent cells.

    I am trying to figure out how to count the "2 times".

    Any ideas guys?
    Last edited by AlienPump; 12-22-2016 at 07:43 AM.

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,570

    Re: count how many times we have the same value in two (or more) adjacent cells

    Try this formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Forum Contributor
    Join Date
    10-19-2012
    Location
    chennai
    MS-Off Ver
    Excel 2013
    Posts
    134

    Re: count how many times we have the same value in two (or more) adjacent cells

    Hi,

    Try attached one.
    Attached Files Attached Files
    RoyalRajan

  4. #4
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Slough
    MS-Off Ver
    Excel 2007
    Posts
    469

    Re: count how many times we have the same value in two (or more) adjacent cells

    There is most likely an easier way to do this but I have added a helper cell underneath that generates words or a number 1 if it is a match.

    Where you se SL on the right then counts all iterations of SL in the top line that has a 1 underneath (The 1 points out that it is the first in the adjacent matches)

    I think this is what you want.
    Attached Files Attached Files

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: count how many times we have the same value in two (or more) adjacent cells

    =SUMPRODUCT((B2:AC2="sl")*(A2:AB2<>"sl"))
    If this was the data...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    1
    1-Jan
    2-Jan
    3-Jan
    4-Jan
    5-Jan
    6-Jan
    7-Jan
    8-Jan
    2
    SL
    SL
    SL
    SL


    Your formula returns a result of 2.

    This array formula** returns a result of 1:

    =SUM(IF(FREQUENCY(IF(A2:H2="SL",COLUMN(A2:H2)),IF(A2:H2<>"SL",COLUMN(A2:H2)))>=2,1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Last edited by Tony Valko; 12-22-2016 at 10:13 AM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    03-27-2012
    Location
    Sofia
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: count how many times we have the same value in two (or more) adjacent cells

    Guys, thanks for all the help, @DannyJ yours works - thank you very much!
    @Tony Valko yours works as well and is actually elegant and very effortless!

    Thanks guys, this has been a huge help!!

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: count how many times we have the same value in two (or more) adjacent cells

    You're welcome. Thanks for the feedback!

+ 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: 4
    Last Post: 02-11-2015, 09:02 AM
  2. Copy the value in a cell, X times to adjacent cells
    By mselbie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2013, 02:00 PM
  3. [SOLVED] Formula needed to only count total cells entered and not count adjacent text entered cells
    By excelteam777 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-07-2013, 06:22 PM
  4. Find percentage of times two adjacent cells have the same data
    By jamie_bisson in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-26-2013, 01:53 AM
  5. [SOLVED] Count in a range, where identical adjacent cells count as one instance.
    By the-algebraist in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-05-2013, 11:18 AM
  6. IF(Name=Name) then Count adjacent cells
    By neilpateluk in forum Excel General
    Replies: 0
    Last Post: 10-14-2009, 11:17 AM
  7. [SOLVED] How to count several non-adjacent cells
    By RMF in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-23-2005, 12:10 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