PDA

View Full Version : Solved: move data in Excel



Lieke
08-27-2008, 07:31 AM
Hi,

Can anyone help me with the following problem? I have data in Excel that are organized in columns of 48 rows each (so column A contains the data in 48 rows, the same goes for column B, C etc etc). But now I need to have my data in one column, so that every 48 cells of each column end up in column A, in the right order (so that A49-A96 contains data from B01-B48, and A97-A144 contains the data from C01-C48 etc).

Can I somehow solve this with VBA?

Thanks in advance!

Bob Phillips
08-27-2008, 08:31 AM
Public Sub Test()
Dim LastCol As Long
Dim i As Long

With ActiveSheet

LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
For i = 2 To LastCol

.Cells(1, i).Resize(48).Cut .Cells((i - 1) * 48 + 1, "A")
Next i
End With

End Sub

Lieke
08-28-2008, 12:10 AM
Thanks very much. This is exactly what I needed!