Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Redim preserve does not work for me

I am trying to understand hoe redim preserve works, but I keep getting run
time error 9

Any idea what is wrong with my redim preserve.
Thank you.
Dan

For example in the bellow:

Public MyReportArray() As Variant
Sub testpreserve()
ReDim MyReportArray(5, 5)
MyReportArray = Range("A5:E5")
ReDim Preserve MyReportArray(6, 6)
MyReportArray = Range("A6:F5")
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Redim preserve does not work for me

From Excel help file....

If you use Preserve, you can only resize the last array dimension and you
can't change the number of dimensions at all.

--

Regards,
Nigel




"Dan" wrote in message
...
I am trying to understand hoe redim preserve works, but I keep getting run
time error 9

Any idea what is wrong with my redim preserve.
Thank you.
Dan

For example in the bellow:

Public MyReportArray() As Variant
Sub testpreserve()
ReDim MyReportArray(5, 5)
MyReportArray = Range("A5:E5")
ReDim Preserve MyReportArray(6, 6)
MyReportArray = Range("A6:F5")
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Redim preserve does not work for me

????
I am not changing the number of dimmensions - always 2

"Nigel" wrote:

From Excel help file....

If you use Preserve, you can only resize the last array dimension and you
can't change the number of dimensions at all.

--

Regards,
Nigel




"Dan" wrote in message
...
I am trying to understand hoe redim preserve works, but I keep getting run
time error 9

Any idea what is wrong with my redim preserve.
Thank you.
Dan

For example in the bellow:

Public MyReportArray() As Variant
Sub testpreserve()
ReDim MyReportArray(5, 5)
MyReportArray = Range("A5:E5")
ReDim Preserve MyReportArray(6, 6)
MyReportArray = Range("A6:F5")
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Redim preserve does not work for me

What Nigel has mentioned is

Dim MyReportArray
ReDim MyReportArray(5, 5)

You can ReDimension to MyReportArray(5,6) or to MyReportArray(5,100)
but cannot
ReDimension to MyReportArray(6,5)

If this post helps click Yes
----------------
Jacob Skaria

"Dan" wrote:

????
I am not changing the number of dimmensions - always 2

"Nigel" wrote:

From Excel help file....

If you use Preserve, you can only resize the last array dimension and you
can't change the number of dimensions at all.

--

Regards,
Nigel




"Dan" wrote in message
...
I am trying to understand hoe redim preserve works, but I keep getting run
time error 9

Any idea what is wrong with my redim preserve.
Thank you.
Dan

For example in the bellow:

Public MyReportArray() As Variant
Sub testpreserve()
ReDim MyReportArray(5, 5)
MyReportArray = Range("A5:E5")
ReDim Preserve MyReportArray(6, 6)
MyReportArray = Range("A6:F5")
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Redim preserve does not work for me

If you declare array in tthis way: MyReportArray = Range("A6:F5") then you
don't need Redim at all.

Public MyReportArray() As Variant
Sub testpreserve()
MyReportArray = Range("A5:E5")
MyReportArray = Range("A6:F5")
End Sub

worked for me and MyReportArray contained cell contents A6:F5.

Regards,
Stefi


€žDan€ť ezt Ă*rta:

????
I am not changing the number of dimmensions - always 2

"Nigel" wrote:

From Excel help file....

If you use Preserve, you can only resize the last array dimension and you
can't change the number of dimensions at all.

--

Regards,
Nigel




"Dan" wrote in message
...
I am trying to understand hoe redim preserve works, but I keep getting run
time error 9

Any idea what is wrong with my redim preserve.
Thank you.
Dan

For example in the bellow:

Public MyReportArray() As Variant
Sub testpreserve()
ReDim MyReportArray(5, 5)
MyReportArray = Range("A5:E5")
ReDim Preserve MyReportArray(6, 6)
MyReportArray = Range("A6:F5")
End Sub





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
Redim Preserve question Sam Kuo[_3_] Excel Programming 11 June 3rd 08 06:38 AM
VBA: What does Redim Preserve do in term of memory Charles Excel Programming 5 January 11th 08 09:53 AM
redim preserve [email protected][_2_] Excel Programming 3 December 15th 05 01:40 PM
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


All times are GMT +1. The time now is 09:55 PM.

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"