Working with Arrays, pasing from function to function
Mike,
Here is an example of what I think you are doing
Function ZipWhere(Zip)
Dim aryZips, aryAreas
Dim iPos As Long
ZipCodes aryZips, aryAreas
On Error Resume Next
iPos = Application.Match(Zip, aryZips, 0)
On Error GoTo 0
If iPos = 0 Then
ZipWhere = CVErr(xlErrNA)
Else
ZipWhere = aryAreas(iPos)
End If
End Function
Function ZipCodes(ByRef pZipCodes, ByRef pZipAreas)
'this is a simulation to load the array
pZipCodes = [{308,401,517}]
pZipAreas = [{"Atlanta GA","Austin TX","Birmingham AL"}]
'your code would be different here, but it
'would load the same arrays
End Function
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"mikebres" wrote in message
...
First let me explain the big picture. I'm trying to make a function to
look
at list of zipcodes. They are listed in this format "Augusta GA" "298,
308-310". City name in one cell and the zips in another. I want the
function
to look at these entries and tell me if a certain zipcode is in the list.
For example if I enter a zip of 309 it should return Augusta GA.
Now, I'm at the point where I have made a function to fill the range into
an
array. The functions leaves me with an array of (308, 309, 310).
I have two questions. First of all is the best way to approach this?
Second if so, what do I need to know about passing arrays from one
function
to another.
Thanks
Mike
|