Seperating data from one column into two columns

C

cshivley

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!
 
N

Norman Jones

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
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top