+ Reply to Thread
Results 1 to 12 of 12

Calculate days between two dates, until job completed.

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    Bucks, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Calculate days between two dates, until job completed.

    I am trying to work out a way to show the increasing number of days between two dates that stops’ increasing once another cell is “Closed Out”

    Column “D” shows the date in which the job is raised, with column “AM” showing the completion date once the “Closed Out” drop down within Column “AK” by using the below Macro (this was my very first ever Macro used, so not experienced in Macro at all)

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 37 Then
    Target(1, 2) = Time
    Target(1, 3) = Date
    Columns("B:C").AutoFit
    End If
    End Sub


    Using the above, this provides me with a way to count the days between start and completion date only, but I am after a way to count the days once the start date is manually entered within Column “D” to increase day-on-day and to stop increasing once Column “AK” is “CLOSED OUT”.

    This number needs to be displayed within Column “C”

    I don't know of a way this can be done using a formula, so Macro may be needed.

    Any help gratefully appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Calculate days between two dates, until job completed.

    Uploading a workbook will get you the answer you want in the most efficient way but a couple of pointers in the meantime.

    1. It's not a good idea to split the date and time... You can store the date AND time in a cell but restrict the display to showing date only using numberformat.

    2. All you need for each record (row) is a start and stop date/time stamp. These can be entered manually or by macro. <--- The time difference can be calulated using StopDateValue-StartDateValue
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    04-29-2013
    Location
    Bucks, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculate days between two dates, until job completed.

    Andy,

    1. Thanks for the tip will look to amend.
    2. unfortunately, the date stamp swill not work. Once the start date in manually entered, there is a period of 7 days in which the job is to be closed out. Using conditional formatting 0-3 days remain white, 4-6 days Yellow, 7+ in red. The time between Start Date & Stop Date is then collected and placed within a graph.

    If I were to just use the Date/Time Stamp for Stop/Start, this will not allow the Conditional Formatting to update each day unless each date within the active jobs are manually altered.

  4. #4
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Calculate days between two dates, until job completed.

    Put this code in your worksheet code module

    Please Login or Register  to view this content.
    Double click on a blank column B to a)enter a start time in B and a calculation in D
    Double click on a calculated time in D and it rplaces it with one final time difference calculation

  5. #5
    Registered User
    Join Date
    04-29-2013
    Location
    Bucks, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculate days between two dates, until job completed.

    Hi Andy,

    I do like this Macro very much and will be placing it within another document I will be working after his, however this Macro continue's to count up even when the Cell "AK" reads "CLOSED OUT".

    Is there any way possible to have the count stop increasing when the above is actioned?

  6. #6
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Calculate days between two dates, until job completed.

    Hi Mac,

    add this code to the worksheet module

    Please Login or Register  to view this content.
    Now you can close the job by double clicking in column D or by entering "Closed Out" in column AK

  7. #7
    Registered User
    Join Date
    04-29-2013
    Location
    Bucks, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculate days between two dates, until job completed.

    This keeps coming up with a Compile Error "Ambiguous Name Deetected" within the below section

    "Private Sub Worksheet_Change(ByVal Target As Range)"




    This is now my entire Macro written within the doc:

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Calculate days between two dates, until job completed.

    It's because there are two Private Sub Worksheet_Change(ByVal Target As Range) subroutines... Replace them with this ..

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-29-2013
    Location
    Bucks, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculate days between two dates, until job completed.

    Hi Andy,

    Your gonna hate me but I am still not able to make this work. Is their a way I can attach the doc to this site?

  10. #10
    Registered User
    Join Date
    04-22-2013
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003/2007 & 2010
    Posts
    90

    Re: Calculate days between two dates, until job completed.

    At the quick reply box, bottom right, there's a button "To go advanced" where you can manage attachements

  11. #11
    Registered User
    Join Date
    04-29-2013
    Location
    Bucks, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Calculate days between two dates, until job completed.

    Brill, Thanks.

    Seems our IT department has blocked uploading docs as well as downloading. Sod it!
    Last edited by StonyMac; 05-03-2013 at 05:15 AM.

  12. #12
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Calculate days between two dates, until job completed.

    I.T... You have to love 'em LOL

+ 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