How do I resize a named array in Excel from a MxN array to a mxn .

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I resize a named array in Excel from a M by N array to a m by n, where
m and n are variables?
 
Either...

Redim NamedArray(m,n)

or if you don't want to lose the cdurrent array contents
when reallocating use...

ReDim Preserve NamedArray(m,n)

HTH,
Gary Brown
 
Look at the ReDim statement in the online-help.
It can only be done with dynamic array:
Eg:
Dim v() as string, v1(2,2) as string
'V1 cannot be re-dimensioned
'For V:
Redim V(1 to 2, 1 to 2)
v(1,1)="hello"
Redim V(1 to 3, 1 to 3) 'above , v is re-dimensioned... v(1,1) is now
empty-string
v(1,1)="world"
Redim Preserve V(1 to 3, 1 to 5) ' By using Preserve you can
re-dimension the
' last dimension of the array without loosing its values, ie
here,
' v(1,1) is still "world"
' but you can only do that on the last dimension.

Regards,
Sebastien
 
CymonM said:
How do I resize a named array in Excel from a M by N array to a m by n, where
m and n are variables?
Well, you've got a couple of partial answers.

What's the difference between your M by N array and the resized array
that is m by n? Is M by N different from m by n??? How is the M by N
array declared?

Alan Beban
 
Alan,

Doesn't the OP just want your ArrayTranspose function?
Or the Excel worksheet function Transpose?

RBS
 
doesn't sound like it

M X N could be 5 x 6 while m x n could be 2 x 15 or 3 x 10 for example.
 
Tom said:
doesn't sound like it

M X N could be 5 x 6 while m x n could be 2 x 15 or 3 x 10 for example.
Or 13 by 17. Once you posit that m is a different size number than M,
there's no reason to think M*N=m*n, unless one were supposed to think
that that was implicit in the use of the word "resize".

And if something like the Transpose were sought, one would think that
the request would be about "resizing" from M by N to N by M.

Hey, the OP seems to be happy with the less than complete answers, so if
he/she is happy I can be happy for him/her.

Alan Beban
 
Alan Beban said:
Or 13 by 17. Once you posit that m is a different size number than M,
there's no reason to think M*N=m*n, unless one were supposed to think
that that was implicit in the use of the word "resize".
....

Depends on whether the OP is used to different programming languages. FWLIW,
in APL

A is 6 5 rho iota 30

creates a 6 by 5 array like {1,2,3,4,5;6,..,10;...;26,..,30}, and

B is 3 11 rho A

is well-defined as

{1,2,..,11;12,13,..,22;23,24,..,30,1,2,3}

It's all a matter of where one's coming from, which the OP should have
stated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top