+ Reply to Thread
Results 1 to 10 of 10

count occasions of sickness

  1. #1
    Registered User
    Join Date
    04-17-2014
    Location
    Dagenham essex
    MS-Off Ver
    Excel 2007
    Posts
    48

    count occasions of sickness

    hi all,

    I need a UDF to help me determine how many occasions of sickness an employee has had. for each week he is sick it's marked as a 1 in my table. the data runs from d2:bb2.

    so if my columns looks like

    111100000111001000111

    the answer would be 4 because he was off sick for 4 weeks the first time then came back and went off sick for another 3 weeks and then back for 2 weeks etc etc

    all help appreciated guys. I need to put the answer in cell bc2

    thanks again

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: count occasions of sickness

    are the 1's and 0's in columns d to bb?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: count occasions of sickness

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-17-2014
    Location
    Dagenham essex
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: count occasions of sickness

    yes nathansav

  5. #5
    Registered User
    Join Date
    04-17-2014
    Location
    Dagenham essex
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: count occasions of sickness

    thanks john, have csn I adapt this to loop through all rows with data as there could be anything from 10 to 1000 employees

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: count occasions of sickness

    Try:

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: count occasions of sickness

    Hi.. try this.

    I have assumed that the employee names were in Column C.. adapt it to suit.

    I have used a helper column (column 85) to transpose each row and then replace the zeros with "" and then count the areas..

    The helper column gets cleared after it is used.

    Check out the attachment.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: count occasions of sickness

    another option:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-17-2014
    Location
    Dagenham essex
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: count occasions of sickness

    thanks apo this works

    but im getting an error when the number of occassions is 0

    how can I fix this

  10. #10
    Registered User
    Join Date
    04-17-2014
    Location
    Dagenham essex
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: count occasions of sickness

    any help appreciated

  11. #11
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: count occasions of sickness

    Hi..

    This will take care of the zero's..

    Please Login or Register  to view this content.
    I tried watersev's code as it looked like a nice idea..

    I modified it slightly to iterate through all your rows and also needed to set the range to be the last used column cell or it would add 1 to the count (as there may well be a area between last used value and bb)..

    Please Login or Register  to view this content.
    Thanks to watersev for this method.. I have never used it before..

    Attached is a workbook showing both options.. you will need to clear column BC before running watersevs (if you have already run mine previously)..
    Attached Files Attached Files

+ 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 Sickness days excluding weekends
    By Cliff Gathern in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-05-2013, 04:18 AM
  2. 2 occasions of percent calculations
    By excelnoonie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2011, 10:09 PM
  3. Sickness Analysis
    By pearson in forum Excel General
    Replies: 4
    Last Post: 06-08-2010, 06:36 PM
  4. Count the number of occasions
    By deemo in forum Excel General
    Replies: 4
    Last Post: 05-22-2009, 12:36 PM
  5. occasions
    By alymcmorland in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2005, 07: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