ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Seperating data from one column into two columns (https://www.excelbanter.com/excel-programming/362371-seperating-data-one-column-into-two-columns.html)

cshivley

Seperating data from one column into two columns
 

I'm not very good at programming. I have one column with values as such:
(x1,y1,x2,y2,x3,y3.......) They alternate from x to y. How can I take
this column and make two columns, one for x and another for y? It is
alot of data, so manual copy and paste is out of the question. Please
help!


--
cshivley
------------------------------------------------------------------------
cshivley's Profile: http://www.excelforum.com/member.php...o&userid=34773
View this thread: http://www.excelforum.com/showthread...hreadid=545344


cshivley[_2_]

Seperating data from one column into two columns
 

The columns looks like this:

x1
y1
x2
y2
x3
y3

Norman Jones

Seperating data from one column into two columns
 
Hi C,

Try:

'=============
Public Sub Tester01()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim destRng As Range
Dim rCell As Range
Dim LastRow As Long
Dim iCol As Long
Const Col As Long = 1 '(column "A") '<<==== CHANGE

Set WB = Workbooks("YourBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet3") '<<===== CHANGE

With SH
LastRow = .Cells(Rows.Count, Col).End(xlUp).Row
Set rng = Range(Cells(2, Col), Cells(LastRow, Col))

rng.Offset(0, 1).Resize(, 2).ClearContents

For Each rCell In rng.Cells
iCol = IIf(iCol = Col + 1, Col + 2, Col + 1)
Set destRng = .Cells(Rows.Count, iCol).End(xlUp)(2)
rCell.Copy destRng
Next rCell
End With

End Sub
'<<=============


---
Regards,
Norman



"cshivley" wrote in
message ...

The columns looks like this:

x1
y1
x2
y2
x3
y3





All times are GMT +1. The time now is 04:18 PM.

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