Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi!
Either you can declare the array as a public variable on the General section of one of the modules and then simply reference the array in both modules since it is a global variable, or you can send it from Sub (or Function) to Sub (or Function) as a parameter. A variant can contain an array so you can allso send the array in a variant parameter but if you know the typw of data you just declare an array without telling the size in the parameter declaration. Example: Sub test() Dim lngArray(10) As Long PopulateArray lngArray() PrintArray lngArray() End Sub Public Sub PopulateArray(ByRef lngArray() As Long) Dim lngLowerBound As Long Dim lngUpperBound As Long Dim lngCounter As Long lngLowerBound = LBound(lngArray) lngUpperBound = UBound(lngArray) For lngCounter = lngLowerBound To lngUpperBound lngArray(lngCounter) = lngCounter Next End Sub Public Sub PrintArray(ByRef lngArray() As Long) Dim lngLowerBound As Long Dim lngUpperBound As Long Dim lngCounter As Long lngLowerBound = LBound(lngArray) lngUpperBound = UBound(lngArray) For lngCounter = lngLowerBound To lngUpperBound Debug.Print lngArray(lngCounter) Next End Sub In this example the three different Subs can be placed in three different modules and still work together. Good luck! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CLASS MODULE & SIMPLE MODULE | Excel Discussion (Misc queries) | |||
Importing Alan Beban's code on Arrays; Importing a module or a project | Excel Worksheet Functions | |||
code in module A to not execute a Worksheet_SelectionChange sub of another module | Excel Discussion (Misc queries) | |||
Module | Excel Discussion (Misc queries) | |||
Variable from a sheet module in a class module in XL XP | Excel Programming |