+ Reply to Thread
Results 1 to 11 of 11

Calculating Rostered Hours

  1. #1
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Calculating Rostered Hours

    I have what is essentially a simple problem, I want to calculate employee rostered hours or days off from an exported crystal reports. The problem isn't how to calculate the hours but to calculate accurately when formatting changes occur in the exported report. This is an example for the exported sheet data.

    \1

    So to calculate data intially using the formula
    Please Login or Register  to view this content.
    works fine.

    But since as you can see the formatting changes in first calculate there are 4 rows for the second day there are 3 rows and if its a day off one row and calculation of next day begins on following row.

    Is there any way to overcome this, I need to learn how to create a macro of this for example the above is from one employee 6 month to december and there are another 70 employs to go.

    My goal would be to end up with output like.

    \1
    Please Login or Register  to view this content.
    The links above contain images showing the examples,, it may be clearer from them the exact layout.
    Last edited by flebber; 01-12-2010 at 05:56 PM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Calculating Rostered Hours

    If you upload an Excel example workbook, we could write a macro, but I'd strongly recommend getting the source right (i.e. find out and address why it's not outputting correctly) - I'm not being idle, if there's a fundamental problem with your source using a macro to get around it will address one problem but might disguise others...

    CC

  3. #3
    Registered User
    Join Date
    01-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003-7
    Posts
    23

    Re: Calculating Rostered Hours

    I won't comment on your Crystal Reports nor completely solve your problem, however, I will show you how to count your hours using built-in FUNCTIONS. Try using:

    =IF(CELL("format",A2)="D1",24*(D2-C2),24*(C2-B2)+E1)

    Now, you have to get the cell references right, I assumed sth like the picture (formula goes in column E).

    Then, to do is grab final value of each date and (if you want) relabel 0 as day-off .

    If you manage to do that w/o macro, it'd be sleek!

    (i would attempt to reverse the formula, starting from bottom up, but that's me)
    Attached Images Attached Images

  4. #4
    Registered User
    Join Date
    01-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003-7
    Posts
    23

    Re: Calculating Rostered Hours

    Did you get it working yet? Anyhow, if you REALLY want a sleek solution w/o using macros, try instead

    =IF(CELL("format",A11)="D1",(D11-C11),C11-B11)+IF(CELL("format",A12)="D1",0,E12)

    That will do the trick. Then, use autofilter and filter out all rows with dates in the first column. You will now have what you were asking for!

  5. #5
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Calculating Rostered Hours

    Quote Originally Posted by zeke varg View Post
    Did you get it working yet? Anyhow, if you REALLY want a sleek solution w/o using macros, try instead

    =IF(CELL("format",A11)="D1",(D11-C11),C11-B11)+IF(CELL("format",A12)="D1",0,E12)

    That will do the trick. Then, use autofilter and filter out all rows with dates in the first column. You will now have what you were asking for!
    OKay going to give it a try I don't instantly understand what you are doing by reading it.

    I had started down a totally different path. Basically using if tests,

    if 1st row has a date record date
    then start calculation
    if 1st cell has time perform calc
    else cell = blank then "day off"
    if end time < 2pm then then row -1
    perform time calc
    elseif perform calculation
    end

  6. #6
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Calculating Rostered Hours

    If i use the =IF(CELL("format",A11 test. How do I make the check if format = date format

    I updated it to match the full worksheet I have so IF(D4("dd/mm/yyyy"") but that isn't working for me.

    Is there an if date/time test like the isnumber test?

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating Rostered Hours

    As already mentioned by CC....

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    A sample file speaks a dozen posts... people are generally disinclined to spend their free time recreating a file based on images when you could just post the file here in the first instance...

    on an aside I doubt you need / want to use CELL function (it's Volatile)

  8. #8
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Calculating Rostered Hours

    Quote Originally Posted by DonkeyOte View Post
    As already mentioned by CC....

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    A sample file speaks a dozen posts... people are generally disinclined to spend their free time recreating a file based on images when you could just post the file here in the first instance...

    on an aside I doubt you need / want to use CELL function (it's Volatile)

    Advice taken, added example workbook.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Calculating Rostered Hours

    Quote Originally Posted by flebber View Post
    Advice taken, added example workbook.
    :D:D:D

    OK, as I mentioned in my first post, it would be better if you could address this by adjusting the source (Clearly, from the example (thanks), it's each new date that adds a value, bumping the lines over) - so I imagine a setting to "print the date for every row" or something like that woudl remove the alginment problem. Again, as stated before, it's better to do this in source as a macro (easily enough written) to fix the alignment might create or mask other problems. It can be clearly seen that the first data row (row 3) would not work with an alignment fix.

    Before we write a macro to fix the alignment, can you please see if you can adjust the source data? I hope I've explained why this is preferable.

    If the data is fixed, we can use formulae or a macro to create your specified view - are you comfortable with VBA?

    CC

  10. #10
    Registered User
    Join Date
    01-12-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003-7
    Posts
    23

    Re: Calculating Rostered Hours

    OKay going to give it a try I don't instantly understand what you are doing by reading it.
    Yeah, it's not obvious, but the key is think in steps; the first test i did gives a hint, it's just checking where the date is and then either adding previous hours or just starting anew. The first one is easier to understand, as it "calculates down", the second one reverses (in order get final sum on date row).

    isn't working for me
    As I mentioned in the first post

    you have to get the cell references right
    Get the references right, then

    use autofilter and filter out all rows with dates in the first column
    That will make your sheet look like the attached one. Note however I updated the formula to exclude lunch bookings (I noticed it looks like you want it that way).

    For DonkeyOte:
    on an aside I doubt you need / want to use CELL function (it's Volatile)
    Please elaborate on this. How would this create an issue in this situation?

    Before writing a macro, always make sure the problem cannot be solved in any other way! It is much more elegant and efficient to use built in functions.

    Of course, getting the report correct from the beginning is a better option, if there is no other point to the format you've chosen. However, that is out of my league and I leave to CC and others to elaborate.
    Attached Files Attached Files
    Last edited by zeke varg; 01-13-2010 at 04:28 PM.

  11. #11
    Forum Contributor
    Join Date
    07-16-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    116

    Re: Calculating Rostered Hours

    I have been toying with crystal reports to get a different output format, the first was a CSV export. This is a bit cleaner output from crystal.

    attached
    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)

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