ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Redim Public Array variables (https://www.excelbanter.com/excel-programming/399969-redim-public-array-variables.html)

Jarle

Redim Public Array variables
 
I have an Array that defined as Public variable.
In procedure1, I Redim this variable and input data.
I procedure2, I try to Redim once more in order to input more data in the
same array.
Is there any way to do this, or will it be impossible to Redim an Public
Array after the initial definition?
Ideas, tricks?

I use procedure below.

Public Arrayname() as String' () in order to define dynamic Array

Sub Procedure1
Redim ArrayName(1 to 10, 3)
' Then I input data into this array
End Sub

Sub Procedure2
Redim Preserve Arrayname(1 to 20,3)
'Input data
End Sub

Dave Peterson

Redim Public Array variables
 
You can redim it all you want--but you can only change the size of the last
dimension.



Jarle wrote:

I have an Array that defined as Public variable.
In procedure1, I Redim this variable and input data.
I procedure2, I try to Redim once more in order to input more data in the
same array.
Is there any way to do this, or will it be impossible to Redim an Public
Array after the initial definition?
Ideas, tricks?

I use procedure below.

Public Arrayname() as String' () in order to define dynamic Array

Sub Procedure1
Redim ArrayName(1 to 10, 3)
' Then I input data into this array
End Sub

Sub Procedure2
Redim Preserve Arrayname(1 to 20,3)
'Input data
End Sub


--

Dave Peterson

Tim Zych

Redim Public Array variables
 
To get that to work, modify the array:

Redim ArrayName(3, 1 to 10)

The last dimension is the one that can be preserved.

Then this will work:

Redim Preserve ArrayNames (3, 1 to 20)


"Jarle" wrote in message
...
I have an Array that defined as Public variable.
In procedure1, I Redim this variable and input data.
I procedure2, I try to Redim once more in order to input more data in the
same array.
Is there any way to do this, or will it be impossible to Redim an Public
Array after the initial definition?
Ideas, tricks?

I use procedure below.

Public Arrayname() as String' () in order to define dynamic Array

Sub Procedure1
Redim ArrayName(1 to 10, 3)
' Then I input data into this array
End Sub

Sub Procedure2
Redim Preserve Arrayname(1 to 20,3)
'Input data
End Sub




Alan Beban[_2_]

Redim Public Array variables
 
Jarle wrote:
I have an Array that defined as Public variable.
In procedure1, I Redim this variable and input data.
I procedure2, I try to Redim once more in order to input more data in the
same array.
Is there any way to do this, or will it be impossible to Redim an Public
Array after the initial definition?
Ideas, tricks?

I use procedure below.

Public Arrayname() as String' () in order to define dynamic Array

Sub Procedure1
Redim ArrayName(1 to 10, 3)
' Then I input data into this array
End Sub

Sub Procedure2
Redim Preserve Arrayname(1 to 20,3)
'Input data
End Sub

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook

ResizeArray ArrayName,,20

Alan Beban


All times are GMT +1. The time now is 04:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com