function result is not propery passed to excel

  • Thread starter Thread starter Nico
  • Start date Start date
N

Nico

Hi,
I have this weird problem.
I have written a function to calculate how many days, hours & minutes people
in my business work. In the VBA editor the function result is correct, but
when I go to Excel the function returns the wrong value.
The code below is where the problem lies:
Public Function AantalInTijd(Datum As Date, tijdformaat As Tijd) As LongIf
tijdformaat = Minuut Then
If tijdformaat = Minuut Then
AantalInTijd = Minute(Datum)
End If
End Function

Now when I check the value of AantalInTijd when it gets its value, it says
40. So when I exit the function, it has that value. Now when I go to
Excel(2003), the function has returned 9 instead of 40. Can anyone help me
with this?

Kind regards,
Nico.
 
Hi Nico,

Your function seems to be corrupted somewhat when pasted into your post.
Can you resend?
What is the value of Minuut and how is it declared?
You didn't really dim tijdformaat as "tijd", did you?
What were the input values?
What if tijdformaat is *not* Minuut?

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


| Hi,
| I have this weird problem.
| I have written a function to calculate how many days, hours & minutes people
| in my business work. In the VBA editor the function result is correct, but
| when I go to Excel the function returns the wrong value.
| The code below is where the problem lies:
| Public Function AantalInTijd(Datum As Date, tijdformaat As Tijd) As LongIf
| tijdformaat = Minuut Then
| If tijdformaat = Minuut Then
| AantalInTijd = Minute(Datum)
| End If
| End Function
|
| Now when I check the value of AantalInTijd when it gets its value, it says
| 40. So when I exit the function, it has that value. Now when I go to
| Excel(2003), the function has returned 9 instead of 40. Can anyone help me
| with this?
|
| Kind regards,
| Nico.
|
|
 
Back
Top