LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default "Compile Error: ByRef argument type mismatch" when calling my func

Jim- thanks for the clarification. Rather than sticking these in cells and
reformatting (since I have thousands) I'll look to see if I can find any way
to format it directly within VBA before passing the parameter.

Thanks!
Keith

"Jim Thomlinson" wrote in message
...
You can not send 39651 into a argument that expects a date... 39651 is a
long
integer. That is a type mismatch. If you put 39651 into a cell and format
it
as a date and send that in to the funciton it will work.
--
HTH...

Jim Thomlinson


"ker_01" wrote:

Excel2003 on WinXP

I have a problem that I'm not sure how to solve; I've decided to post the
short version first (in case it is easy and someone can tell me how to
fix
it). If that doesn't work I'll post the much longer description with more
code (I drafted the post, then was overwhelmed by the size of the
potential
post and whether anyone would even read it all). Basically, I'm getting a
byref error when trying to call a function in a different module. It may
be
that the function expects a date and my values are a numeric
representation
of the date- that's my best guess right now, even though I'd think Excel
knows the number represents a valid date?

'Module1
'--------------------------------------------------------------------------
Public IntermediateArray As Variant
'I set this equal to a sheetrange to set the size, then do lots of data
manipulations on the array contents
'IntermediateArray(n, 10) is a department code, like "Engineering"
'IntermediateArray(n, 15) is a number representing the days since
1/1/1900,
such as 39651
'--------------------------------------------------------------------------

'Module2
'--------------------------------------------------------------------------
Option Base 1

Public Function LoadStaffing(DeptID As String, uDate As Date) As Variant
'do stuff
LoadStaffing = Array(rVal1, rVal2, rVal3)

End Function
'--------------------------------------------------------------------------

I tested the function within the same module by using the following sub,
and
it returns the expected value:
'--------------------------------------------------------------------------
Sub Test_staffingmodel()
X = LoadStaffing("Engineering", "8/1/2008")
MsgBox X(1)
End Sub
'--------------------------------------------------------------------------

However, Module3, I try to use the function like this:
'--------------------------------------------------------------------------
Dim AvailableTime_ThisDayThisDept as variant
AvailableTime_ThisDayThisDept = LoadStaffing(IntermediateArray(eachday,
10),
IntermediateArray(eachday, 15))
'--------------------------------------------------------------------------
and when the sub gets called, I get "Compile Error: ByRef argument type
mismatch" error. The code in other modules has already finished running
(it
takes about 8 minutes to run). As far as I can tell, it dies here at the
module level, it does not run and then crash at this line of code. I
checked
some of the other variables in this module with debug.print and it
doesn't
appear that any of them are populated with values from the sub's code.

Is this an issue with the date format not being able to accept numbers?
Or
some weird cross-module limitation of variant arrays?

Thanks for any advice,
Keith





 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ByRef Argument Type Mismatch Sprinks Excel Programming 5 August 8th 08 04:11 PM
ByRef Argument Type mismatch Tone[_4_] Excel Programming 4 July 3rd 08 02:35 PM
HELP "ByRef Argument Type Mismatch" RocketMan[_2_] Excel Programming 6 June 7th 07 07:00 PM
"ByRef argument type mismatch" Error Baapi[_4_] Excel Programming 2 September 17th 05 12:47 AM
ByRef argument type mismatch error? sermest Excel Programming 4 June 17th 05 06:50 PM


All times are GMT +1. The time now is 02:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"