Consulting

Results 1 to 10 of 10

Thread: Micro for TAT

  1. #1
    VBAX Regular
    Joined
    Apr 2009
    Posts
    40
    Location

    Question Micro for TAT

    Hi expert,

    I have a micro fucntion which name is Getworkday for calculate TAT but its not remove holiday list. Its working but only not remove holiday list.

    Code

    Function GetWorkdays(FirstDate As Date, LastDate As Date, _
    Optional Hols As Variant) As Integer
    Dim i As Integer, ii As Integer, wkdys As Integer
    Dim dy As Date
    Dim f As Boolean
    wkdys = 0
    For i = 0 To (LastDate - FirstDate)
    dy = CDate(FirstDate + i)
    If Weekday(dy) <> 1 Then
    f = False
    If Not IsMissing(Hols) Then
    For ii = 1 To Hols.Count
    If Len(Hols(ii)) = 0 Then Exit For
    If CDate(Hols(ii)) = dy Then
    f = True
    Exit For
    End If
    Next
    End If
    If Not f Then wkdys = wkdys + 1
    End If
    Next
    GetWorkdays = wkdys
    End Function

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What is wrong with the WORKDAY function?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Apr 2009
    Posts
    40
    Location
    Dear,

    I have to calculate TAT Excluding sunday and holiday between two date. If i calculate with networkday function then it exclude starday and sunday.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can do it with a formula

    =SUMPRODUCT(INT((MAX(end_date,start_date)-WEEKDAY(MAX(end_date,start_date)+1-{2;3;4;5;6;7})-MIN(end_date,start_date)+8)/7))
    -SUMPRODUCT(ISNUMBER(MATCH(WEEKDAY(holidays),{2;3;4;5;6;7},0))*(holidays>=MI N(end_date,start_date))*(holidays<=MAX(end_date,start_date)))

    bu what is wrong with your UDF? I have given it a quick trial and it seems to work to m. Show an example where it doesn't work.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Apr 2009
    Posts
    40
    Location

    Question

    Dear Xld,

    i have attached the sheet kindly check it and i need like this calculated formula if any plz guid me

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why should it be 3, 4 looks right to me.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is this the problem

    For i = 0 To (LastDate - FirstDate)

    should it be

    For i = 1 To (LastDate - FirstDate)
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    VBAX Regular
    Joined
    Apr 2009
    Posts
    40
    Location

    Question

    Dear

    when i delete holiday date from E column then it should increase TAT value but it does not show any effect while i calculate networkdays its shows effect.
    Suppose i have no of holidays list then what to do.
    I hope there is date with timing issue. if i calculate remove time then it work correctly.

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What are the rules for time, the impact on the number of days?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    VBAX Regular
    Joined
    Apr 2009
    Posts
    40
    Location
    Dear,
    i have done and thanx for your support

    =IF(GetWorkdays(Q2,U2)=0,1,IF(HOUR(Q2)>15,GetWorkdays(TEXT(Q2,"mm/dd/yyyy"),U2,BE$1:BR$1)-2,GetWorkdays(TEXT(Q2,"mm/dd/yyyy"),U2,BE$1:BR$1)-1))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •