Consulting

Results 1 to 4 of 4

Thread: Solved: Run-Time Error "13" - Type Mismatch

  1. #1
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location

    Solved: Run-Time Error "13" - Type Mismatch

    Hi,

    I run a program from my machine and it works perfectly, I tried it from a colleagues machine and it works perfectly, unfortunately a further colleague runs the program and gets a run time, type mismatch error.

    On debug it comes up at the following script:

    [VBA]Private Function CalculateMonthDays(ByVal StartDate As Date, _
    ByVal EndDate As Date, _
    ByVal FromDate As Date, _
    ByVal ToDate As Date) As Long

    If (StartDate >= FromDate And StartDate <= ToDate) Or _
    (EndDate >= FromDate And EndDate <= ToDate) Then

    If FromDate > StartDate Then StartDate = FromDate
    If ToDate < EndDate Then EndDate = ToDate
    CalculateMonthDays = wsAbsence.Evaluate("NETWORKDAYS(" & cLng(StartDate) & "," & CLng(EndDate) & ")")

    End If
    End Function
    Private Function CalculateWeekDays(ByVal StartDate As Date, _
    ByVal EndDate As Date, _
    ByVal FromDate As Date, _
    ByVal ToDate As Date) As Long

    If (StartDate >= FromDate And StartDate <= ToDate) Or _
    (EndDate >= FromDate And EndDate <= ToDate) Then

    If FromDate > StartDate Then StartDate = FromDate
    If ToDate < EndDate Then EndDate = ToDate
    CalculateWeekDays = wsAbsence.Evaluate("NETWORKDAYS(" & CLng(StartDate) & "," & CLng(EndDate) & ")")
    End If
    End Function[/VBA]

    it stops on the particular line
    [VBA]CalculateMonthDays = wsAbsence.Evaluate("NETWORKDAYS(" & cLng(StartDate) & "," & CLng(EndDate) & ")")[/VBA]


    Would anyone know the reason this happens on only 1 machine?
    Is there anything I can do to correct the error?

    Incidentally, it occurs when the number being input is 0.5 don't know if that makes a difference.

    Any help appreciated
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    They don't have the Add-In, Analysis Toolpak, selected?
    Last edited by Kenneth Hobs; 05-29-2009 at 06:49 AM.

  3. #3
    VBAX Mentor Hoopsah's Avatar
    Joined
    Nov 2007
    Posts
    303
    Location
    Ahh!!

    Cheers Kenneth - I will go and fix their machine now.

    Thanks for your help

    Hoopsah
    I am playing all the right notes, but not necessarily in the right order.
    Eric Morecambe

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Another thought, has your colleague got a non-English version of Excel?
    ____________________________________________
    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

Posting Permissions

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