Hi, If anyone can help!!
I have a global array where I set the bounds once the user makes a selection. The user has choices that would cause the array to grow but because you cannot redim Preserve the lower bounds of a multidimensional array, I thought I save what was there is a temp array, erase & redim the global array one larger then reset the global array to the temp array and add the new chioce. It does not error on the code but it doesn't ever increase the UBound of the first element:
In Module:
Global AnArray()
Global intArryCntr as Integer
Once UserMakesSelection:
gintArryCntr = NumberOfVersions
ReDim AnArray(1 To gintArryCntr, cNumOfElements)
'** Populate each element of array with each version
If User added a Version:
Sub ResetArray()
Dim intNewBounds As Integer
Dim aTemp() As Variant
intNewBounds = gintArryCntr + 1
ReDim aTemp(1 To intNewBounds, cNumOfElements)
aTemp = AnArray
Erase AnArray
gintArryCntr = intNewBounds
ReDim AnArray(1 To gintArryCntr, cNumOfElements)
AnArray = aTemp
Erase aTemp
End Sub
Sub PopulateNewVersion(ArrayIndex as integer)
'** Code to populate the new version
AnArray(ArrayIndex, 1) = (whatever) -> FAILS HERE w. Script out of range. I did a Print UBound and it was the same as the first ReDim.
End Sub
Any ideas or alternative solutions?
Thanks!
I have a global array where I set the bounds once the user makes a selection. The user has choices that would cause the array to grow but because you cannot redim Preserve the lower bounds of a multidimensional array, I thought I save what was there is a temp array, erase & redim the global array one larger then reset the global array to the temp array and add the new chioce. It does not error on the code but it doesn't ever increase the UBound of the first element:
In Module:
Global AnArray()
Global intArryCntr as Integer
Once UserMakesSelection:
gintArryCntr = NumberOfVersions
ReDim AnArray(1 To gintArryCntr, cNumOfElements)
'** Populate each element of array with each version
If User added a Version:
Sub ResetArray()
Dim intNewBounds As Integer
Dim aTemp() As Variant
intNewBounds = gintArryCntr + 1
ReDim aTemp(1 To intNewBounds, cNumOfElements)
aTemp = AnArray
Erase AnArray
gintArryCntr = intNewBounds
ReDim AnArray(1 To gintArryCntr, cNumOfElements)
AnArray = aTemp
Erase aTemp
End Sub
Sub PopulateNewVersion(ArrayIndex as integer)
'** Code to populate the new version
AnArray(ArrayIndex, 1) = (whatever) -> FAILS HERE w. Script out of range. I did a Print UBound and it was the same as the first ReDim.
End Sub
Any ideas or alternative solutions?
Thanks!