 
    
    
 
	
	
		
		
	
	
	
	
	
		
			
- 
	
	
		
		
			
				
				
				
					Solved: Redim Preserve Multi Dimensional dynamic Array
				
					
						
							I have been trying to preserve data in a multidimensional dynamic array and it fails.  runtime 9. using excel 2003 on thinkpad T61P
 
 Sub test()
 Dim testarry() As Integer
 ReDim testarry(2, 2)
 testarry(0, 0) = 1
 testarry(0, 1) = 2
 testarry(1, 0) = 3
 testarry(1, 1) = 4
 ReDim Preserve testarry(3, 2)
 testarry(2, 0) = 5
 MsgBox testarry(0, 0)
 End Sub
 
 
 
 
 
 
 
- 
	
	
		
		
			
				
				
						
						
				
					
						
							crap.  help is pretty good:
 If you use the Preserve keyword, you can resize only the last  array dimension and you can't change the number of dimensions at all. For  example, if your array has only one dimension, you can resize that dimension  because it is the last and only dimension. However, if your array has two or  more dimensions, you can change the size of only the last dimension and still  preserve the contents of the array. The following example shows how you can  increase the size of the last dimension of a dynamic array without erasing any  existing data contained in the array.
 ReDim X(10, 10, 10)
 . . .
 ReDim Preserve X(10, 10, 15)
 
 
 
 
 
 
 
- 
	
	
		
		
			
				
				
						
						
							
						
				
					
						
							"crap. help is pretty good:"
 
 Thanks burtburt.  Also thanks for posting your follow up.
 
 
 
 
 
 
 
 
	
	
	
	
	
	
	
	
	
	
	
	
		
		
			
				 Posting Permissions
				Posting Permissions
			
			
				
	
		- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-  
Forum Rules