+ Reply to Thread
Results 1 to 5 of 5

Logic advice for max hours in week that overlaps month

  1. #1
    Registered User
    Join Date
    08-17-2014
    Location
    England
    MS-Off Ver
    Small Business Edition 2003
    Posts
    3

    Question Logic advice for max hours in week that overlaps month

    Hi all,

    I can't quite get my head around how to achieve something, hence looking for some logic advice and how people think it would work best in VBA.

    I have a scheduler which is simply Mon to Fri and number of hours each day that a task is worked on. So some might be 5 hours in a week and others could be 50 hours in a week. Every week I want to double the hours but to a maximum of 15, so the 5 week hour would get 5 additional hours and the 50 week hour would get additional 15. Make sense so far?

    My problem is that this has to be calculated monthly and when I calculate the following month it takes no account of the bonus hours that were allocated the previous month in the overlapping week. So where September and October overlap in a week my code at present could potentially allocate 15 bonus hours for the last two days of September and then again for the week when calculating October through the last three days. Make sense?

    Here is the code -
    Please Login or Register  to view this content.
    vbmin is a simple function which returns the smaller of the two numbers being passed to it.

    So any ideas how I should reduce the first weeks bonus hours to compensate for any bonus hours claimed for that week in the previous month?

    Thanks in advance,

    Brad
    Last edited by bradsalmon; 08-17-2014 at 04:54 PM. Reason: code tags added

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,952

    Re: Logic advice for max hours in week that overlaps month

    Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Ben Van Johnson

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,088

    Re: Logic advice for max hours in week that overlaps month

    bradsalmon,
    Welcome on board.
    Certainly you notice protonLeah's reminder and to go forward faster please send a sample of your data it will make like easier to check your code.
    PCI
    - Battle without fear gives no glory - Just try

  4. #4
    Registered User
    Join Date
    08-17-2014
    Location
    England
    MS-Off Ver
    Small Business Edition 2003
    Posts
    3

    Re: Logic advice for max hours in week that overlaps month

    thanks protonLeah, I hadn't appreciated that.
    Now updated.

  5. #5
    Registered User
    Join Date
    08-17-2014
    Location
    England
    MS-Off Ver
    Small Business Edition 2003
    Posts
    3

    Re: Logic advice for max hours in week that overlaps month

    Hi PCI,
    I did think about a sample of the data, however then I would of had to include more of the code that loops through it as well. So I decided to try and keep it as small as possible by placing the sample data into the code. I understand the downside but hopefully I can work around the checks myself.
    Brad

+ 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: 0
    Last Post: 08-14-2013, 11:21 AM
  2. [SOLVED] Showing Fridays of each month in a 4 week month and a five week month
    By david_j_p in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-09-2013, 06:27 AM
  3. Total hours and paid hours calculation advice
    By lozzauk in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-27-2013, 08:25 AM
  4. Replies: 0
    Last Post: 07-12-2012, 01:47 PM
  5. Replies: 10
    Last Post: 01-22-2012, 10:05 AM

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