View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How to reference a public array (declared in module) from a proced

There were a couple of typos/mistakes. For completeness here is a cleaned
up version (although it sounds like you got what you needed).

Sub Main()
Dim myArr(1 To 10) As String
For i = 1 To 10
myArr(i) = Chr(i + 64) & Chr(i + 65) & Chr(i + 66)
Next
setSelections myArr


End Sub

Public Sub setSelections(ArrayName() As String)
For i = LBound(ArrayName) To UBound(ArrayName)
sStr = sStr & ArrayName(i) & ", "
If i Mod 5 = 0 Then
MsgBox sStr
sStr = ""
End If
Next
End Sub

--
Regards,
Tom Ogilvy

"Amzee" wrote in message
...
Hi Tom,

It worked fine when I used Public Sub setSelections(arrayName() as String)

Regards.

"Amzee" wrote:

I can reference a listbox in a Worksheet using the following

Public Sub Procedure1(worksheetName As String, listBoxName As String)
Dim listSize As Integer
listSize =

Worksheets(worksheetName).OLEObjects(listBoxName). Object.ListCount
.....
end sub

How do I do the same for a public array (declared in a module) with the
following procedure??

Public Sub setSelections(arrayName as String)
????.....
end sub

Thanks!