ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sorting Data in a column (https://www.excelbanter.com/excel-discussion-misc-queries/45090-sorting-data-column.html)

BigAndy

Sorting Data in a column
 
I am trying to extract data that is in a single column to split it into 3
columns. The data is cyclic and has 3 variables, a time, a data point and a
random number. These simply run abcabcabcabc down the column and i would
like to get all of the a's into a column, all of the b's into another column
and all of the c's into a third column.

any ideas?

Bob Phillips

VBA?

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
If iLastRow Mod 3 < 1 Then iLastRow = iLastRow - 1
If iLastRow Mod 3 < 1 Then iLastRow = iLastRow - 1
For i = iLastRow To 1 Step -3
Cells(i, "C").Value = Cells(i + 2, "A").Value
Cells(i, "B").Value = Cells(i + 1, "A").Value
Rows(i + 1).Resize(2).Delete
Next i

End Sub


--
HTH

Bob Phillips

"BigAndy" wrote in message
...
I am trying to extract data that is in a single column to split it into 3
columns. The data is cyclic and has 3 variables, a time, a data point and

a
random number. These simply run abcabcabcabc down the column and i would
like to get all of the a's into a column, all of the b's into another

column
and all of the c's into a third column.

any ideas?





All times are GMT +1. The time now is 06:59 PM.

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