Assumption: We have list of values in excel sheet1
row1: A1
row2: A2
row3: A3
row4: A4
row5: B1
row6: B2
row7: B3
row8: B4
Task: We want to transpose this data in excel sheet2 into form.
row1: A1A2A3A4
row2: B1B2B3B4
So every four cells in four rows is transposed to one row with four columns
It could be done using following Visual Basic Macro:
<code>
- Sub Macro()
- RowIndex = 1
- Do
- Sheets(“Sheet1″).Select
- With Sheets(“Sheet1″)
- Range(.Cells(RowIndex, 1), .Cells(RowIndex + 3, 1)).Select
- End With
- Selection.Copy
- Sheets(“Sheet2″).Select
- RowIndexPaste = Round(RowIndex / 4) + 1
- With Sheets(“Sheet2″)
- Range(.Cells(RowIndexPaste, 1), .Cells(RowIndexPaste, 1)).Select
- End With
- Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
- False, Transpose:=True
- RowIndex = RowIndex + 4
- Loop While Sheets(“Sheet1″).Cells(RowIndex, 1).Value <> “”
- End Sub
</code>
Macro check until check empty line.
If you know easiest way to resolve this task, let me know!