Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problems Converting 1-D Array to 2-D Array
I had d 1-D array which I was loading with cell addresses
within a For Loop. I was redimensionin the array based on a counter witin my loop since I don't know how big to make it. It was working fine. Then I decided to introduce a second dimension. All I wanted to do was introduce a new column in the array which I was not yet filling. That is, I still want to my data to go into column 0. I can't seem to load the array with data. I have skipped out how I progress though the cells as this is extensive code. But I have included the main lines. I have done something wrong in the new version. Can anyone tell me what I have done wrong? Thanks Old: UniqueCount = 0 ReDim UniqueCellAddressArray(0 To 0) For X = 1 to 100 UniqueCount = UniqueCount + 1 ReDim Preserve UniqueCellAddressArray(0 To UniqueCount) UniqueCellAddressArray(UniqueCount, 0) = CurrentCell1.Parent.Name & "!" & CurrentCell1.Address Debug.Print UniqueCellAddressArray(UniqueCount) Next New: UniqueCount = 0 ReDim UniqueCellAddressArray(0 To 0, 0 To 0) UniqueCount = UniqueCount + 1 ReDim Preserve UniqueCellAddressArray(0 To UniqueCount, 0 To 1) UniqueCellAddressArray(UniqueCount, 0) = CurrentCell1.Parent.Name & "!" & CurrentCell1.Address Debug.Print UniqueCellAddressArray(UniqueCount, 0) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problems Converting 1-D Array to 2-D Array
You can only redim the outer/last dimension of an array when you use
preserve. This is explained in the help on dynamic arrays. -- Regards, Tom Ogilvy "ExcelMonkey" wrote in message ... I had d 1-D array which I was loading with cell addresses within a For Loop. I was redimensionin the array based on a counter witin my loop since I don't know how big to make it. It was working fine. Then I decided to introduce a second dimension. All I wanted to do was introduce a new column in the array which I was not yet filling. That is, I still want to my data to go into column 0. I can't seem to load the array with data. I have skipped out how I progress though the cells as this is extensive code. But I have included the main lines. I have done something wrong in the new version. Can anyone tell me what I have done wrong? Thanks Old: UniqueCount = 0 ReDim UniqueCellAddressArray(0 To 0) For X = 1 to 100 UniqueCount = UniqueCount + 1 ReDim Preserve UniqueCellAddressArray(0 To UniqueCount) UniqueCellAddressArray(UniqueCount, 0) = CurrentCell1.Parent.Name & "!" & CurrentCell1.Address Debug.Print UniqueCellAddressArray(UniqueCount) Next New: UniqueCount = 0 ReDim UniqueCellAddressArray(0 To 0, 0 To 0) UniqueCount = UniqueCount + 1 ReDim Preserve UniqueCellAddressArray(0 To UniqueCount, 0 To 1) UniqueCellAddressArray(UniqueCount, 0) = CurrentCell1.Parent.Name & "!" & CurrentCell1.Address Debug.Print UniqueCellAddressArray(UniqueCount, 0) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Converting an Array to value's | Excel Discussion (Misc queries) | |||
meaning of : IF(Switch; Average(array A, array B); array A) | Excel Worksheet Functions | |||
Array problems | Excel Discussion (Misc queries) | |||
Converting column to array | Excel Worksheet Functions | |||
Problems populating an array | Excel Programming |