PDA

View Full Version : Solved: Run-Time Error "13" - Type Mismatch



Hoopsah
05-29-2009, 06:29 AM
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:

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

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


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 :dunno

Kenneth Hobs
05-29-2009, 06:39 AM
They don't have the Add-In, Analysis Toolpak, selected?

Hoopsah
05-29-2009, 06:48 AM
Ahh!!

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

Thanks for your help

Hoopsah

Bob Phillips
05-29-2009, 08:23 AM
Another thought, has your colleague got a non-English version of Excel?