View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Stephen Bullen[_3_] Stephen Bullen[_3_] is offline
external usenet poster
 
Posts: 74
Default Arrays as Arguments in Functions

Hi Dean,

I'm having some trouble with this function. I want to
preserve the values of array between calls to a function.
But I cannot figure out how to define the argument for the
function and what the call function statement should look
like. Has anyone done this?


Something like this (untested):

Sub Test()

Dim asStuff(0 to 1) As String

asStuff(0) = "Hello"
asStuff(1) = "Goodbye"

MsgBox WhatString(asStuff)

End Sub

Function WhatString(ByRef asArray() As String) As String
WhatString = asArray(0) & ", " & asArray(1)
End Function

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.ie