Rearrange numbers from a column in a different order in a second c

G

Guest

Hi, I'm using Excel 2003 on Windows. I have a list of 4800 numbers in a
column divided by groups of 5 within a larger group of 80. I need to
rearrange them in a second column with a different order but with a pattern.
Each group of five consecutive numbers are separated by a jump of 6 numbers
up to 75, starting at number ''1''. By using exactly the same pattern, start
this time with number ''6'' up to 80. The same pattern is repeated from 81 to
160, ... up to 4800.

I'm not an expert. Is there an efficient way to rearrange these numbers? Any
help would be great!

In other words, in column A, you have numbers from 1 to 4800. In column B, I
need the numbers to be in the following order:

A B

1 1 1st group of 80
2 2
3 3
4 4
5 5
6 11
7 12
8 13
9 14
10 15
11 21
12 22
13 23
14 24
15 25
16 31
17 32
18 33
19 34
20 35
'' ''
'' ''
36 71
37 72
38 73
39 74
40 75
41 6
42 7
43 8
44 9
45 10
46 16
47 17
48 18
49 19
50 20
51 26
52 27
53 28
54 29
55 30
56 36
57 37
58 38
59 39
60 40
61 46
62 47
63 48
64 49
65 50
66 56
67 57
68 58
69 59
70 60
71 66
72 67
73 68
74 69
75 70
76 76
77 77
78 78
79 79
80 80 2nd group of 80 with identical pattern to group 1
81 81
82 82
83 83
84 84
85 85
86 91
87 92
88 93
89 94
90 95
'' ''
151 146
152 147
153 148
154 149
155 150
156 156
157 157
158 158
159 159
160 160

Thanks a lot!
 
M

macropod

Hi Gaetan58,

For Column A data starting on row 1, try using this formula in Column B:
=INT((A1-1)/5)*10+MOD((A1-1),5)+1+INT((A1-1)/40)*5-INT((A1-1)/40)*80+INT((A1
-1)/80)*70

Cheers
 
G

Guest

gaetae,
1. if u say numbers, on column A,
a. is it in sequence <min to max or max to min>
b. is it a mixture of different numbers, not in order, (i.e. %,
Currency, Date, etc.)
c. if it is "", do you mean it is a blank cell, or a text number "n" ?
pls. be specific about the details of your numbers, for any reason why you
group them..
 
G

Guest

The data are % which could be negative. The '' '' was just to say that the
series are continuing following the same pattern. These % are not in order.
Each group of five are data associated with one compound. They have to be
rearranged because they are automatically plotted on a graph with very
complex algorythms.

Thanks for your interest to fix my problem.
 
L

Leo Heuser

Gaetan58 said:
Hi, I'm using Excel 2003 on Windows. I have a list of 4800 numbers in a
column divided by groups of 5 within a larger group of 80. I need to
rearrange them in a second column with a different order but with a
pattern.
Each group of five consecutive numbers are separated by a jump of 6
numbers
up to 75, starting at number ''1''. By using exactly the same pattern,
start
this time with number ''6'' up to 80. The same pattern is repeated from 81
to
160, ... up to 4800.

I'm not an expert. Is there an efficient way to rearrange these numbers?
Any
help would be great!

In other words, in column A, you have numbers from 1 to 4800. In column B,
I
need the numbers to be in the following order:

A B

1 1 1st group of 80
2 2
3 3
4 4
5 5
6 11
7 12
8 13
9 14
10 15
11 21
12 22
13 23
14 24
15 25
16 31
17 32
18 33
19 34
20 35
'' ''
'' ''
36 71
37 72
38 73
39 74
40 75
41 6
42 7
43 8
44 9
45 10
46 16
47 17
48 18
49 19
50 20
51 26
52 27
53 28
54 29
55 30
56 36
57 37
58 38
59 39
60 40
61 46
62 47
63 48
64 49
65 50
66 56
67 57
68 58
69 59
70 60
71 66
72 67
73 68
74 69
75 70
76 76
77 77
78 78
79 79
80 80 2nd group of 80 with identical pattern to group 1
81 81
82 82
83 83
84 84
85 85
86 91
87 92
88 93
89 94
90 95
'' ''
151 146
152 147
153 148
154 149
155 150
156 156
157 157
158 158
159 159
160 160

Thanks a lot!


Hi

Here's a VBA solution, which reorganizes the contents of
the datacells according to the given rules and puts the result
into the cells to the right of the datarange.

The values for Outer, Inner and the number of cells in
the datarange may be altered. It's left as an exercise
to the reader to spot the principles behind :)

Put the routine in a general module (<Alt><F11>, Insert > Module)

Sub Reorganize()
'Leo Heuser, 19 Nov. 2006
Dim Counter As Long
Dim Counter1 As Long
Dim Counter2 As Long
Dim DataRange As Range
Dim DataRangeValue As Variant
Dim Dummy As Long
Dim Inner As Long
Dim Outer As Long
Dim Reorganized() As Variant

Outer = 80
Inner = 5
Set DataRange = Sheets("Sheet1").Range("A2:A4801")


DataRangeValue = DataRange.Value

ReDim Reorganized(1 To UBound(DataRangeValue), 1 To 1)

For Counter = LBound(DataRangeValue) To _
UBound(DataRangeValue) Step Outer
For Counter1 = 1 To Outer Step Inner
For Counter2 = 1 To Inner
Dummy = Counter + Counter1 + Counter2 - 2

If Dummy > Counter + Outer / 2 - 1 Then
Reorganized(Dummy, 1) = _
DataRangeValue(Dummy - Outer + _
Inner * (Int(Counter1 / Inner) + 1), 1)
Else
Reorganized(Dummy, 1) = _
DataRangeValue(Dummy + Counter1 - 1, 1)
End If
Next Counter2
Next Counter1
Next Counter

DataRange.Offset(0, 1).Value = Reorganized

End Sub
 
G

Guest

Hi macropod,

Terrific! It works! Thanks a lot! I would have never been able to find that
by myself. If I ever have to change the column reference e.g data in column A
and data reaaranged in column D), would it affect only a part of the formula
or a totally new formula is required?

I really appreciate! I'm also impressed by the help from the community!



macropod said:
Hi Gaetan58,

For Column A data starting on row 1, try using this formula in Column B:
=INT((A1-1)/5)*10+MOD((A1-1),5)+1+INT((A1-1)/40)*5-INT((A1-1)/40)*80+INT((A1
-1)/80)*70

Cheers

--
macropod
[MVP - Microsoft Word]


Gaetan58 said:
Hi, I'm using Excel 2003 on Windows. I have a list of 4800 numbers in a
column divided by groups of 5 within a larger group of 80. I need to
rearrange them in a second column with a different order but with a pattern.
Each group of five consecutive numbers are separated by a jump of 6 numbers
up to 75, starting at number ''1''. By using exactly the same pattern, start
this time with number ''6'' up to 80. The same pattern is repeated from 81 to
160, ... up to 4800.

I'm not an expert. Is there an efficient way to rearrange these numbers? Any
help would be great!

In other words, in column A, you have numbers from 1 to 4800. In column B, I
need the numbers to be in the following order:

A B

1 1 1st group of 80
2 2
3 3
4 4
5 5
6 11
7 12
8 13
9 14
10 15
11 21
12 22
13 23
14 24
15 25
16 31
17 32
18 33
19 34
20 35
'' ''
'' ''
36 71
37 72
38 73
39 74
40 75
41 6
42 7
43 8
44 9
45 10
46 16
47 17
48 18
49 19
50 20
51 26
52 27
53 28
54 29
55 30
56 36
57 37
58 38
59 39
60 40
61 46
62 47
63 48
64 49
65 50
66 56
67 57
68 58
69 59
70 60
71 66
72 67
73 68
74 69
75 70
76 76
77 77
78 78
79 79
80 80 2nd group of 80 with identical pattern to group 1
81 81
82 82
83 83
84 84
85 85
86 91
87 92
88 93
89 94
90 95
'' ''
151 146
152 147
153 148
154 149
155 150
156 156
157 157
158 158
159 159
160 160

Thanks a lot!
 
M

macropod

Hi Gaetan58,

Changing the column would only entail changing the column reference.
Changing the starting row would mean changing all the 1s by a corresponding
amount.

Cheers

--
macropod
[MVP - Microsoft Word]


Gaetan58 said:
Hi macropod,

Terrific! It works! Thanks a lot! I would have never been able to find that
by myself. If I ever have to change the column reference e.g data in column A
and data reaaranged in column D), would it affect only a part of the formula
or a totally new formula is required?

I really appreciate! I'm also impressed by the help from the community!



macropod said:
Hi Gaetan58,

For Column A data starting on row 1, try using this formula in Column B:
=INT((A1-1)/5)*10+MOD((A1-1),5)+1+INT((A1-1)/40)*5-INT((A1-1)/40)*80+INT((A1
-1)/80)*70

Cheers

--
macropod
[MVP - Microsoft Word]


Gaetan58 said:
Hi, I'm using Excel 2003 on Windows. I have a list of 4800 numbers in a
column divided by groups of 5 within a larger group of 80. I need to
rearrange them in a second column with a different order but with a pattern.
Each group of five consecutive numbers are separated by a jump of 6 numbers
up to 75, starting at number ''1''. By using exactly the same pattern, start
this time with number ''6'' up to 80. The same pattern is repeated
from 81
to
160, ... up to 4800.

I'm not an expert. Is there an efficient way to rearrange these
numbers?
Any
help would be great!

In other words, in column A, you have numbers from 1 to 4800. In
column B,
I
need the numbers to be in the following order:

A B

1 1 1st group of 80
2 2
3 3
4 4
5 5
6 11
7 12
8 13
9 14
10 15
11 21
12 22
13 23
14 24
15 25
16 31
17 32
18 33
19 34
20 35
'' ''
'' ''
36 71
37 72
38 73
39 74
40 75
41 6
42 7
43 8
44 9
45 10
46 16
47 17
48 18
49 19
50 20
51 26
52 27
53 28
54 29
55 30
56 36
57 37
58 38
59 39
60 40
61 46
62 47
63 48
64 49
65 50
66 56
67 57
68 58
69 59
70 60
71 66
72 67
73 68
74 69
75 70
76 76
77 77
78 78
79 79
80 80 2nd group of 80 with identical pattern to group 1
81 81
82 82
83 83
84 84
85 85
86 91
87 92
88 93
89 94
90 95
'' ''
151 146
152 147
153 148
154 149
155 150
156 156
157 157
158 158
159 159
160 160

Thanks a lot!
 
L

Leo Heuser

macropod said:
Hi Gaetan58,

For Column A data starting on row 1, try using this formula in Column B:
=INT((A1-1)/5)*10+MOD((A1-1),5)+1+INT((A1-1)/40)*5-INT((A1-1)/40)*80+INT((A1
-1)/80)*70

Cheers


Hi macropod

The OP's posting indicates, that data is various percentages, positive
and/or negative and in no particular order.

Quote:
The data are % which could be negative. The '' '' was just to say that the
series are continuing following the same pattern. These % are not in order.
Each group of five are data associated with one compound. They have to be
rearranged because they are automatically plotted on a graph with very
complex algorythms.
End quote


Your clever formula doesn't reorganize the *contents* of the cells but
"only" the numbering. In other words, if the OP's data is in A1:A4800,
column B1:B4800 is a helper column containing the numbers from
1 through 4800. Your formula is entered in C1:C4800, and the result is,
that C1:C4800 contains the reorganization of B1:B4800. In order
to get the *contents* of A1:A4800 reorganized, the formula in C1
must be:

=INDEX($A$1:$A$4800,INT((B1-1)/5)*10+MOD((B1-1),5)+1+INT((B1-1)/40)*5-INT((B1-1)/40)*80+INT((B1
-1)/80)*70)


On the other hand, I may have misunderstood the problem completely.
My VBA solution reorganizes the contents.
 
M

macropod

Hi Leo,
The OP's posting indicates, that data is various percentages, positive
and/or negative and in no particular order.

The OP's original post clearly showed a consecutive integer sequence, 1 to
4800, apparently starting in A1. The problem was to reproduce the desired
number sequence, which is what my solution does - I could just as easily
have used ROW() instead of the A1 reference.

I am also aware that there was a mention of percentages the day after I
posted my reply but, nonetheless, the OP said my solution provided the
answer sought. Maybe that's because it was being used as a key (eg via
INDEX, MATCH, OFFSET or LOOKUP, etc) to the percentages.
Your clever formula doesn't reorganize the *contents* of the cells but
"only" the numbering.

That's all I was trying to do.
My VBA solution reorganizes the contents.

But it gives the wrong result:
A B C
1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 11
12 22 22
13 23 23
14 24 24
15 25 25
16 26 31
22 42 42
23 43 43
24 44 44
25 45 45
26 46 51
32 62 62
33 63 63
34 64 64
35 65 65
36 66 71
The original sequence is 'A', your's is 'B' and mine is 'C'.

Cheers
 
L

Leo Heuser

"macropod" <[email protected]> skrev i en meddelelse

I am also aware that there was a mention of percentages the day after I
posted my reply but, nonetheless, the OP said my solution provided the
answer sought. Maybe that's because it was being used as a key (eg via
INDEX, MATCH, OFFSET or LOOKUP, etc) to the percentages.

You are probably right about that.

But it gives the wrong result:
A B C
1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 11
12 22 22
13 23 23
14 24 24
15 25 25
16 26 31
22 42 42
23 43 43
24 44 44
25 45 45
26 46 51
32 62 62
33 63 63
34 64 64
35 65 65
36 66 71
The original sequence is 'A', your's is 'B' and mine is 'C'.

And if your testdata was in A1:A4800, you remembered to set the
datarange in my subroutine (which was A2:A4801) to A1:A4800
prior to running the sub ;-)

Leo Heuser
 
G

Guest

hello mvp macropod and Leo Heuser,
I am glad to find both of you to give the best solution, will it be okey if
i re-post this thread with a condition that data on column A is considering
Gaetae's 2nd explanation under driller's question...are you willing to try
and give the exact solution based on these ? pls. reply.
 
G

Guest

Hi,

My problem is solved! I would like to thank everyone of you for your
interest in my question. You were so helpful!

Best regards,

Gaetan58
 
L

Leo Heuser

p said:
hello mvp macropod and Leo Heuser,
I am glad to find both of you to give the best solution, will it be okey
if
i re-post this thread with a condition that data on column A is
considering
Gaetae's 2nd explanation under driller's question...are you willing to try
and give the exact solution based on these ? pls. reply.

I may be a bit dense, but what is Gaetae's 2nd explanation?
Please provide an example of what you're trying to accomplish.

Regards
Leo Heuser
 

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

Top