Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting an Array to value's Gunti Excel Discussion (Misc queries) 12 November 3rd 08 02:51 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Array problems Bruce D. Excel Discussion (Misc queries) 4 September 28th 06 09:36 PM
Converting column to array asaylor Excel Worksheet Functions 0 August 7th 06 08:02 PM
Problems populating an array John N. Excel Programming 1 July 22nd 04 10:31 PM


All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"