View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default Passing arrays through procedures

Hi Brian, Sort is a reserved word in VBA code for the Sort function. When
you use it as a Macro name it conflicts with the internal libraries and
throws an error. You need to modify the macro name. Something lik Srt or
sSort or mSort...as long as the compiler can tell it is not the function
Sort.


"Brian" wrote in message
...
All,

I'm getting a compile error: Type mismatch: array or user-defined type
expected on the "Call Sort(arrDate)" line. What should I be looking for to
troubleshoot this? Below are the lines of code that deal with arrDate.

Sub Button17_Click()
ReDim arrDate(0)
Call GetMonths(arrDate,arrSite)
Call SiteSelected(arrDate,arrSite)
End Sub

Sub GetMonths(arrDate, arrSite as Variant)
'Here is where I build arrDate and send to Sort to get them in order
Call Sort(arrDate)
End Sub

Sub Sort(arr() as Variant)
'Sort array in order
End Sub

Sub SiteSelected(arrDate,arrSite as Variant)
'Here arrDate is actually used
End Sub

I know my arrDate array gets built properly because it appears correctly
in
the SiteSelected Procedure when I skip the Sort Procedure. Clearly I don't
know how to pass arrays through procedures effectively so any help with
that
would be appreciated also.
--
Brian