Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Excel Array Conversion from 2-Dimensional to One

Re : Excel Array Conversion from 2-Dimensional to One

1. Enter an Excel worksheet.

2. Enter into the range A1 : C1 = A, C, E.
3. Enter into the range A2 : C2 = B, U, T.
4. Enter into the range A3 : C3 = C, O, P.
5. Enter into the range A4 : C4 = D, I, G.
6. Enter into the range A5 : C5 = E, L, F.

7. Enter a formula into cell D1 = COUNTIF(A1:C5,A1:C5).

8. Partial evaluation of the formula in the formula bar shows that cell
D1 ={1,2,2;1,1,1;2,1,1;1,1,1;2,1,1} (i.e., 2-dimensional array).

9. Now, the question is, how to transform the formula in cell D1 such
that it would evaluate to D1 = {1;2;2;1;1;1;2;1;1;1;1;1;2;1;1} (i.e.,
One-dimensional array).

10. Please share your comment.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Excel Array Conversion from 2-Dimensional to One

You'll need to clarify step 7. If one enters in cell D1:
=COUNTIF(A1:C5,A1:C5)
the result is zero.

If, however, one creates a two-dimensional array with the upper-left corner
in D1 such that the formulas are like so:
D1 = COUNTIF($A$1:$C$5,A1)
D2 = COUNTIF($A$1:$C$5,A2)
D3 = COUNTIF($A$1:$C$5,A3)
.....and so on until
F5 = COUNTIF($A$1:$C$5,C5)

then one returns a two-dimensional array meeting your description
(i.e, {1,2,2;1,1,1;2,1,1;1,1,1;2,1,1})

From there, the dirtiest solution would be to concatenate the values
together to return a fifteen character string: 122111211111211 (with comma
separators optional).

Again, please clarify step 7. Also, if the source array varies in size, a
programmatic solution may be best.

Glenn Ray
MOS Expert

" wrote:

Re : Excel Array Conversion from 2-Dimensional to One

1. Enter an Excel worksheet.

2. Enter into the range A1 : C1 = A, C, E.
3. Enter into the range A2 : C2 = B, U, T.
4. Enter into the range A3 : C3 = C, O, P.
5. Enter into the range A4 : C4 = D, I, G.
6. Enter into the range A5 : C5 = E, L, F.

7. Enter a formula into cell D1 = COUNTIF(A1:C5,A1:C5).

8. Partial evaluation of the formula in the formula bar shows that cell
D1 ={1,2,2;1,1,1;2,1,1;1,1,1;2,1,1} (i.e., 2-dimensional array).

9. Now, the question is, how to transform the formula in cell D1 such
that it would evaluate to D1 = {1;2;2;1;1;1;2;1;1;1;1;1;2;1;1} (i.e.,
One-dimensional array).

10. Please share your comment.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Excel Array Conversion from 2-Dimensional to One

Thank you for your reply.

7. To rephrase step 7 ; Enter a formula into cell D1 =
COUNTIF(A1:C5,A1:C5) ; to be Array-Entered, then a value 1 is
instantantly visible in cell D1.

D1 = COUNTIF(A1:C5,A1:C5) and D1 {= COUNTIF(A1:C5,A1:C5)} evaluate
similarly in the formula bar (by virtue of partial evaluation after
selecting either form of the formula at the equal sign and move to the
right end).

Regards.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Excel Array Conversion from 2-Dimensional to One

wrote:
Re : Excel Array Conversion from 2-Dimensional to One

1. Enter an Excel worksheet.

2. Enter into the range A1 : C1 = A, C, E.
3. Enter into the range A2 : C2 = B, U, T.
4. Enter into the range A3 : C3 = C, O, P.
5. Enter into the range A4 : C4 = D, I, G.
6. Enter into the range A5 : C5 = E, L, F.

7. Enter a formula into cell D1 = COUNTIF(A1:C5,A1:C5).

8. Partial evaluation of the formula in the formula bar shows that cell
D1 ={1,2,2;1,1,1;2,1,1;1,1,1;2,1,1} (i.e., 2-dimensional array).

9. Now, the question is, how to transform the formula in cell D1 such
that it would evaluate to D1 = {1;2;2;1;1;1;2;1;1;1;1;1;2;1;1} (i.e.,
One-dimensional array).

10. Please share your comment.

I'm not sure what you mean by "D1=(1,2,2;1 . . .)" In fact, if the
formula is array entered into D1:F5 then D1=1, E1=2, F1=2, D2=1, E2=1,
F2=1, etc., through F5; i.e., D1:F5 (not D1) contains the
two-dimensional array you describe.

If instead you want the corresponding "one-dimensional" array (it will
in fact be two-dimensional if transferred to VBA) in D1:R1, then if the
functions in the freely downloadable file at
http:/home.pacbell.net/beban are available to your workbook then either
of the following, array entered into D1:R1, will produce the result:

=MakeArray(COUNTIF(A1:C5,A1:C5),1)

=ArrayReshape(COUNTIF(A1:C5,A1:C5),1,15)

Alan Beban
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Excel Array Conversion from 2-Dimensional to One

Will study your suggestion. Thank you.



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
Using a two-dimensional array in Excel 2002 or 2003 rwjack New Users to Excel 4 January 24th 08 04:27 PM
Create One-Dimensional Array from Two-Dimensional Array Stratuser Excel Programming 1 February 23rd 05 08:46 PM
Do I need a two dimensional array for this? hotherps[_17_] Excel Programming 1 February 20th 04 04:46 PM
add to two dimensional array GUS Excel Programming 1 August 26th 03 12:12 AM
2 Dimensional Array steve Excel Programming 0 August 18th 03 07:19 PM


All times are GMT +1. The time now is 07:34 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"