ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to split column? (https://www.excelbanter.com/excel-programming/303549-how-split-column.html)

Y. Belenky

How to split column?
 
Help please,
I've one long column (~65000 rows) of data in one sheet.
The question is how to split it to several columns
with 400 (for example) rows of the data in each?
Is there any known macro?
Thank you very much,
Y.B.


Tom Ogilvy

How to split column?
 
Sub AAA()
Dim i As Long, j As Long, n As Long
j = 0
For i = 1 To 65536 Step 400
j = j + 1
n = 400
If n + i 65536 Then _
n = 65536 - i + 1
Cells(i, 1).Resize(n, 1).Copy Destination:= _
Worksheets("Sheet2").Cells(1, j)
Next
End Sub


--
Regards,
Tom Ogilvy




"Y. Belenky" wrote in message
...
Help please,
I've one long column (~65000 rows) of data in one sheet.
The question is how to split it to several columns
with 400 (for example) rows of the data in each?
Is there any known macro?
Thank you very much,
Y.B.




Y. Belenky

How to split column?
 
Thank you Tom!
Y.B.


Tom Ogilvy wrote:
Sub AAA()
Dim i As Long, j As Long, n As Long
j = 0
For i = 1 To 65536 Step 400
j = j + 1
n = 400
If n + i 65536 Then _
n = 65536 - i + 1
Cells(i, 1).Resize(n, 1).Copy Destination:= _
Worksheets("Sheet2").Cells(1, j)
Next
End Sub




All times are GMT +1. The time now is 07:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com