Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

Dynamic array defined outside sub, redimensioned in one macro and use in another macr

$
0
0
Dear All,

I am trying to do something like:

Public dynarr() As String

Sub data1()

Size = 3
ReDim arr(Size) As String

For i = 1 To Size Step 1
arr(i) = Cells(i, 1)
Next i

Call data

End Sub

Sub data2()
Size = 7
ReDim arr(Size) As String

For i = 1 To Size Step 1
arr(i) = Cells(i + 10, 1)
Next i

Call data

End Sub

Sub data()

For i = 1 To Size
Cells(i, 2) = arr(i)
Next i

End Sub


But, it's asking to redefine the dimension of arr(). Am I doing wrong or it's not possible to define dynamic array in a way, I did. Actually I have one common code after reading all the data (user selected, so the row selection is random) from worksheets. So, trying to redimension arr() in each macro and then do operate in a common macro.

Any help will be appreciated.

Viewing all articles
Browse latest Browse all 21243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>