Passing Arrays to a Sub

B

Brad

I have an array of strings (sIssue) made up of different strings concatanated
together. The way sIssue will be constructed will be used repeatedly in my
program so what I would like to do is write a subroutine to construct this
array for the main program. I'm just not sure how to do this. I would like
for the code to work something like below

Sub Main()

' Do stuff
dim sIssue (1 to 8) as string

GetString(sIssue())

Range("B1").Select
for i = 1 to 8
ActiveCell.Offset(i,0).Value = sIssue(i)
next

End
-----------------
sub GetString(Byval sIssue as string)

' do stuff
for i = 1 to 8
sIssue(i) = ActiveCell.Offset(i,0) & ActiveCell.Offset(i,2)
next
End

Thanks in advance

end sub
 
B

Bob Phillips

Sub Main()
' Do stuff
dim sIssue As Variant
sIssue = GetString()

For i = 1 to 8
Cells(i,"B").Value = sIssue(i)
Next
End Sub

Private Function GetString() As Variant
' do stuff
for i = 1 to 8
GetString(i) = ActiveCell.Offset(i,0) & ActiveCell.Offset(i,2)
Next
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top