Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default redim preserve

hi, ive read through previous threads and im struggling to understand
dynamic arrays., specifically resizing. Basically Im using a dynamic
array 2 cols wide with variable rows. Im using ReDim Preserve
CapturePowers(1 To x, 1 To 2)
CapturePowers(x, 1) = name
CapturePowers(x, 2) = 0
Ive read you can only redim the last array which is were im lost. Im
assuming in my array that 1 to x is the rows, and 1 to 2 is the cols. I
can use redim with single arrays fine. I can work out the size Of the
array before using it and wondering if this is the best option or the
only option.
Hope this makes sense
regards Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default redim preserve

You seem to have a good handle on this. Your choices are to work out the
size before or to create the array as 2 rows deep and X columns wide. In
other words, to transpose it. If you really needed a 'vertical' array you
could create it from the 'horizontal' array afterwards.

--
Jim
wrote in message
oups.com...
| hi, ive read through previous threads and im struggling to understand
| dynamic arrays., specifically resizing. Basically Im using a dynamic
| array 2 cols wide with variable rows. Im using ReDim Preserve
| CapturePowers(1 To x, 1 To 2)
| CapturePowers(x, 1) = name
| CapturePowers(x, 2) = 0
| Ive read you can only redim the last array which is were im lost. Im
| assuming in my array that 1 to x is the rows, and 1 to 2 is the cols. I
| can use redim with single arrays fine. I can work out the size Of the
| array before using it and wondering if this is the best option or the
| only option.
| Hope this makes sense
| regards Robert
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default redim preserve

You can only resize the last DIMENSION of a multi-dimensional array...

ReDim Preserve CapturePowers(1 To 999, 1 To x)
ReDim Preserve ThreeDimArray(1 To 999, 1 To 999, 1 To x)

.... therefore, you can add "columns" but not "rows" It's a pain in the
butt. You can write a "GridFlip" function to swap rows to columns, add a
column, and flip columns back to rows!

" wrote:

hi, ive read through previous threads and im struggling to understand
dynamic arrays., specifically resizing. Basically Im using a dynamic
array 2 cols wide with variable rows. Im using ReDim Preserve
CapturePowers(1 To x, 1 To 2)
CapturePowers(x, 1) = name
CapturePowers(x, 2) = 0
Ive read you can only redim the last array which is were im lost. Im
assuming in my array that 1 to x is the rows, and 1 to 2 is the cols. I
can use redim with single arrays fine. I can work out the size Of the
array before using it and wondering if this is the best option or the
only option.
Hope this makes sense
regards Robert


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default redim preserve

Thankyou both for your replies. Ive decided to take the easy way, and
calculate the array before using it. Easy to do than I thought, thanks
for advice.
Regards Robert

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
VBA syntax help: ReDim Preserve an array Dave Excel Discussion (Misc queries) 4 September 8th 07 07:37 PM
Code for optimization, ReDim Preserve not handling it well, HELP please! [email protected] Excel Programming 0 November 2nd 05 08:18 AM
Redim Preserve doesn't work Witek[_2_] Excel Programming 3 November 1st 04 11:34 PM
ReDim, Preserve and Multidimensional arrays Andy Westlake[_2_] Excel Programming 3 October 19th 04 07:04 PM
ReDim Problem Casey[_4_] Excel Programming 4 January 7th 04 10:41 PM


All times are GMT +1. The time now is 12:24 AM.

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

About Us

"It's about Microsoft Excel"