+ Reply to Thread
Results 1 to 8 of 8

Count Blocks of occurances within a range

  1. #1
    Registered User
    Join Date
    12-22-2014
    Location
    London, England
    MS-Off Ver
    Professional Plus 2010
    Posts
    4

    Post Count Blocks of occurances within a range

    Hello All,

    This is my first posting here. I have a problem I have been trying to solve for some weeks now.

    I have a sheet for recording staff sickness etc. I can count the number of days a member of staff is sick or late in a range, but i need to count the number of periods of sick in the same range.

    I have attached an example. In cell AB4 i want to count the number of Periods of sick (3 in this case) - in order that later I can calculate bradford factor.

    I would really be very grateful for some pointers or guidance guys.

    Thank you!

    Andy Brown
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Count Blocks of occurances within a range

    Try this user defined function.

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a AB4, enter =SickPeriodCount(D4:Y4)

    and copy down.

    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

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

    Re: Count Blocks of occurances within a range

    Try this array formula**:

    =SUM(IF(FREQUENCY(IF(D4:Y4="S",COLUMN(D4:Y4)),IF(D4:Y4<>"S",COLUMN(D4:Y4))),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.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    12-22-2014
    Location
    London, England
    MS-Off Ver
    Professional Plus 2010
    Posts
    4

    Re: Count Blocks of occurances within a range

    Thank you so much guys! Apologies for the late response, I've been off sick.

    Both solutions work perfectly, but we will use the function.

    Much appreciated, this has been bugging me for ages!

  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 Blocks of occurances within a range

    You're welcome. We appreciate the feedback!

    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

  6. #6
    Registered User
    Join Date
    12-22-2014
    Location
    London, England
    MS-Off Ver
    Professional Plus 2010
    Posts
    4

    Re: Count Blocks of occurances within a range

    Hello All,

    I open this thread again because for the next FY my reporting requirements have changed.

    mrice wrote me a nice little function (see above) that I have been using over the last year, however now I need to be able to do the same thing, but counting "S" as well as "\"

    "S" represents a whole day sick "\" represents a half day.

    So i need to count the number of periods of sickness in a period not just the number of days.

    therefore if there a 3 "S" followed by a "\" or vice versa this needs to be counted as one period of sickness.

    I hope this makes sense, and once again I am more than happy to donate a little something to anyone who can help provide a solution.

    Thanks again in anticipation!

    Andy

  7. #7
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Count Blocks of occurances within a range

    Maybe this modification will work for you.


    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-22-2014
    Location
    London, England
    MS-Off Ver
    Professional Plus 2010
    Posts
    4

    Re: Count Blocks of occurances within a range

    Thank you so much again!! Your modification works perfectly. Having spent most of yesterday having a go myself, I don't think I was far off, just couldn't get the logic and the brackets in the right places.

    Once again you've saved me a huge amount of work. Very much appreciated. Good luck on the 24th April!

    Andy

+ 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: 5
    Last Post: 05-11-2012, 03:38 AM
  2. Count the number of occurances of a value in a range.
    By pi**edasanewt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-15-2008, 07:08 AM
  3. Count occurances in range of cells
    By Ed Gregory in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-07-2005, 03:05 PM
  4. [SOLVED] count date occurances in range of dates...
    By Alex in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  5. count date occurances in range of dates...
    By Alex in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-27-2005, 12:05 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