Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can anyone show me how to correctly pass an array of strings
to a function or sub? How do I define the function as well? Here is an example for you to study (the subroutine names should tell you what you need to know)... Sub SubWithArrayArgument(Arr() As String) MsgBox "UpperBound = " & UBound(Arr) & vbLf & "Last element = " & Arr(UBound(Arr)) End Sub Sub CallSubWithArrayArgument() Dim MyArr() As String MyArr = Split("one,two,three,four", ",") SubWithArrayArgument MyArr End Sub Just run the CallSubWithArrayArgument subroutine (which could be a macro if need be). It will create the MyArr array inside itself and then pass it to the SubWithArrayArgument subroutine which will display the index for the last element in that passed in array and also the value in that last element. Obviously, the setup and passing mechanism would be the same for functions as well. Hope this helps. Rick Rothstein (MVP - Excel) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sorting a text strings but omitting preceding "A" or "The" | Excel Worksheet Functions | |||
=IF function, reference problem to "text strings" in Data Validati | Excel Discussion (Misc queries) | |||
How do I use "offset" function in "array formula"? | Excel Discussion (Misc queries) | |||
Listbox header inside VBA (Array("Head1", "Head2", ...) | Excel Programming | |||
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... | Excel Programming |