Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Passing array from 2nd sub back to first sub

I have a sub which calls a second sub. The second sub
loads an array. I want to pass the entire array back up
to the first sub when the second sub is completed. How do
I this assuming that I do not want to make the array a
public array?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Passing array from 2nd sub back to first sub

ExcelMonkey,

1) Dimension the Array as Private within the module containing the two subs

or

2) Pas the Array ByRef to the second sub

Sub FirstSub()
Dim i As Integer
Dim myArray(1 To 10) As String

'Pass the array to the second sub
SecondSub myArray

For i = 1 To 10
MsgBox myArray(i)
Next i
End Sub

Sub SecondSub(ByRef myArray2 As Variant)
Dim i As Integer
'Modify the array
For i = 1 To 10
myArray2(i) = "Test " & i
Next i
End Sub

HTH,
Bernie
MS Excel MVP

"ExcelMonkey" wrote in message
...
I have a sub which calls a second sub. The second sub
loads an array. I want to pass the entire array back up
to the first sub when the second sub is completed. How do
I this assuming that I do not want to make the array a
public array?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Passing array from 2nd sub back to first sub

Thanks Bernie


-----Original Message-----
ExcelMonkey,

1) Dimension the Array as Private within the module

containing the two subs

or

2) Pas the Array ByRef to the second sub

Sub FirstSub()
Dim i As Integer
Dim myArray(1 To 10) As String

'Pass the array to the second sub
SecondSub myArray

For i = 1 To 10
MsgBox myArray(i)
Next i
End Sub

Sub SecondSub(ByRef myArray2 As Variant)
Dim i As Integer
'Modify the array
For i = 1 To 10
myArray2(i) = "Test " & i
Next i
End Sub

HTH,
Bernie
MS Excel MVP

"ExcelMonkey" wrote

in message
...
I have a sub which calls a second sub. The second sub
loads an array. I want to pass the entire array back up
to the first sub when the second sub is completed. How

do
I this assuming that I do not want to make the array a
public array?




.

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
Need help passing an array as an argument blc[_3_] Excel Programming 3 August 4th 04 10:35 PM
PASSING an array to a sub in VBA Wombat[_2_] Excel Programming 2 November 30th 03 11:48 AM
Passing data back from a form Chris A[_3_] Excel Programming 0 November 27th 03 11:53 PM
Passing data back from a form Taras Excel Programming 0 November 24th 03 04:33 PM
Passing data back from a form Tom Ogilvy Excel Programming 0 November 24th 03 04:27 PM


All times are GMT +1. The time now is 01:37 AM.

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

About Us

"It's about Microsoft Excel"