Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Problem with Alan Beban's ResizeArray

Trying to use Alan Beban's Sub ResizeArray, but I can't get it to work.
There are no errors, but the final array after resizing has all empty
elements.
It goes wrong at the final bit where the altered array is assigned to the
supplied array:

MsgBox arr1(1, 2)

'goes wrong here
MyArray = arr1

MsgBox MyArray(1, 2)

MsgBox SuppliedArray(1, 2)

The first 2 messageboxes give the right value, but the third gives a blank.
The array supplied to the sub is a 2-dimensional 1-based publicly declared
variant array.
I must be making a simple mistake, but I can't see it.
Thanks for any advice.


RBS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Problem with Alan Beban's ResizeArray

Hi RB,

I'm not sure what your code looks like, but with 1 through 12 in A1:C4 I
ran the following

Option Base 1
Public SuppliedArray() As Variant
_________________________________
Sub TestArrayFill()
ReDim SuppliedArray(1 To 4, 1 To 3)
Set rng = Sheets(4).Range("A1:C4")
For i = 1 To 4
For j = 1 To 3
SuppliedArray(i, j) = rng(i, j)
Next
Next
ResizeArray SuppliedArray, 5, 3
For i = 1 To 5: For j = 1 To 3
Debug.Print SuppliedArray(i, j)'<-returned 1 thru 12 plus 3 blanks
Next
Next
Debug.Print UBound(SuppliedArray)'<-returned 5
End Sub

Where are we not running the same thing?

Alan Beban

RB Smissaert wrote:
Trying to use Alan Beban's Sub ResizeArray, but I can't get it to work.
There are no errors, but the final array after resizing has all empty
elements.
It goes wrong at the final bit where the altered array is assigned to the
supplied array:

MsgBox arr1(1, 2)

'goes wrong here
MyArray = arr1

MsgBox MyArray(1, 2)

MsgBox SuppliedArray(1, 2)

The first 2 messageboxes give the right value, but the third gives a blank.
The array supplied to the sub is a 2-dimensional 1-based publicly declared
variant array.
I must be making a simple mistake, but I can't see it.
Thanks for any advice.


RBS


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Problem with Alan Beban's ResizeArray

Alan,

Thanks.
I had my SuppliedArray declared as a fixed array:
Public SuppliedArray(1 To 200, 1 To 35) As Variant
That was the difference.
After changing to:
Public SuppliedArray() As Variant
and doing
ReDim SuppliedArray(1 To 200, 1 To 35) As Variant
on initializing the form it works.

I knew it would be something simple.

Bart




"Alan Beban" wrote in message
...
Hi RB,

I'm not sure what your code looks like, but with 1 through 12 in A1:C4 I
ran the following

Option Base 1
Public SuppliedArray() As Variant
_________________________________
Sub TestArrayFill()
ReDim SuppliedArray(1 To 4, 1 To 3)
Set rng = Sheets(4).Range("A1:C4")
For i = 1 To 4
For j = 1 To 3
SuppliedArray(i, j) = rng(i, j)
Next
Next
ResizeArray SuppliedArray, 5, 3
For i = 1 To 5: For j = 1 To 3
Debug.Print SuppliedArray(i, j)'<-returned 1 thru 12 plus 3 blanks
Next
Next
Debug.Print UBound(SuppliedArray)'<-returned 5
End Sub

Where are we not running the same thing?

Alan Beban

RB Smissaert wrote:
Trying to use Alan Beban's Sub ResizeArray, but I can't get it to work.
There are no errors, but the final array after resizing has all empty
elements.
It goes wrong at the final bit where the altered array is assigned to

the
supplied array:

MsgBox arr1(1, 2)

'goes wrong here
MyArray = arr1

MsgBox MyArray(1, 2)

MsgBox SuppliedArray(1, 2)

The first 2 messageboxes give the right value, but the third gives a

blank.
The array supplied to the sub is a 2-dimensional 1-based publicly

declared
variant array.
I must be making a simple mistake, but I can't see it.
Thanks for any advice.


RBS



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Problem with Alan Beban's ResizeArray

Thanks for the feedback.

Alan Beban

RB Smissaert wrote:
Alan,

Thanks.
I had my SuppliedArray declared as a fixed array:
Public SuppliedArray(1 To 200, 1 To 35) As Variant
That was the difference.
After changing to:
Public SuppliedArray() As Variant
and doing
ReDim SuppliedArray(1 To 200, 1 To 35) As Variant
on initializing the form it works.

I knew it would be something simple.

Bart




"Alan Beban" wrote in message
...

Hi RB,

I'm not sure what your code looks like, but with 1 through 12 in A1:C4 I
ran the following

Option Base 1
Public SuppliedArray() As Variant
_________________________________
Sub TestArrayFill()
ReDim SuppliedArray(1 To 4, 1 To 3)
Set rng = Sheets(4).Range("A1:C4")
For i = 1 To 4
For j = 1 To 3
SuppliedArray(i, j) = rng(i, j)
Next
Next
ResizeArray SuppliedArray, 5, 3
For i = 1 To 5: For j = 1 To 3
Debug.Print SuppliedArray(i, j)'<-returned 1 thru 12 plus 3 blanks
Next
Next
Debug.Print UBound(SuppliedArray)'<-returned 5
End Sub

Where are we not running the same thing?

Alan Beban

RB Smissaert wrote:

Trying to use Alan Beban's Sub ResizeArray, but I can't get it to work.
There are no errors, but the final array after resizing has all empty
elements.
It goes wrong at the final bit where the altered array is assigned to


the

supplied array:

MsgBox arr1(1, 2)

'goes wrong here
MyArray = arr1

MsgBox MyArray(1, 2)

MsgBox SuppliedArray(1, 2)

The first 2 messageboxes give the right value, but the third gives a


blank.

The array supplied to the sub is a 2-dimensional 1-based publicly


declared

variant array.
I must be making a simple mistake, but I can't see it.
Thanks for any advice.


RBS




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
Importing Alan Beban's code on Arrays; Importing a module or a project Steve G Excel Worksheet Functions 4 August 27th 07 04:18 PM
Has anyone used arrayfunctions from Alan Beban? SteveT Excel Worksheet Functions 3 February 26th 07 07:52 AM
VlookupS-Alan Beban Deeds Excel Worksheet Functions 4 December 20th 05 12:03 AM
Array Functions from Alan Beban Josh O. Excel Worksheet Functions 13 February 5th 05 12:54 AM


All times are GMT +1. The time now is 11:08 PM.

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"