Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to reference a public array (declared in module) from a proced

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to reference a public array (declared in module) from a proced

Assuming arrayname is a single dimension array of type string.

Public Sub setSelections(arrayName as String)
for i = lbound(arrayname) to ubound(arrayname)
sStr = msg & arrayname(i) & ", "
if i mod 5 = 0 then
msgbox msg
sStr = ""
end if
Next
end sub

--
Regards,
Tom Ogilvy


"Amzee" wrote in message
...
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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to reference a public array (declared in module) from a proced

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!

  #4   Report Post  
Posted to microsoft.public.excel.programming
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!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference a variable declared in VBA James Excel Worksheet Functions 3 September 12th 08 10:31 PM
Declaring variables in Module vs. Public Jeff Excel Discussion (Misc queries) 5 November 19th 07 08:27 PM
Passing Public Module Vairable to a Worksheet Event SMS - John Howard Excel Programming 1 November 4th 04 08:33 AM
declaring a public array JT[_2_] Excel Programming 3 July 27th 04 11:18 PM
Public Array Brent McIntyre Excel Programming 5 September 23rd 03 12:53 AM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"