transforming 1d (1column) into 5d(5column) matrix through copy paste or other

Posted by Curious on Stack Overflow See other posts from Stack Overflow or by Curious
Published on 2010-05-20T04:10:59Z Indexed on 2010/05/20 4:20 UTC
Read the original article Hit count: 203

Ex. I want to take the column with 12345..... and order 5 columns across as seen. next 5 numbers in column will be next row. However my code creates a 4 row gap in between each successive row. I dont know what additional logic (possibly if then statement) I can embed into do loop to may make it cleaner. I am new to this, so showing as much sample code to learn the syntax would be most beneficial. thanks in advance.

Below is the Result of my code. VBA code is below result.

1 1 2 3 4 5 2
3
4
5
6 6 7 8 9 10 7
8
9
10
11 11 12 13 14 15 12
13
14
15
16 16 17
17

Sub Working_Code() ' Working_Code Macro

Do ActiveCell.Select Selection.Copy ActiveCell.Offset(0, 5).Select ActiveSheet.Paste ActiveCell.Offset(1, -5).Select

Selection.Copy
ActiveCell.Offset(-1, 6).Select
ActiveSheet.Paste
ActiveCell.Offset(2, -6).Select

Selection.Copy
ActiveCell.Offset(-2, 7).Select
ActiveSheet.Paste
ActiveCell.Offset(3, -7).Select

Selection.Copy
ActiveCell.Offset(-3, 8).Select
ActiveSheet.Paste
ActiveCell.Offset(4, -8).Select

Selection.Copy
ActiveCell.Offset(-4, 9).Select
ActiveSheet.Paste
ActiveCell.Offset(5, -9).Select

Loop Until IsEmpty(ActiveCell.Offset(0, -1))

End Sub

© Stack Overflow or respective owner

Related posts about transform

Related posts about column