Sorting lots of data

ka86

New Member
Joined
Mar 2, 2011
Messages
2
Ok I don't know if anybody can help me.

Here's a selection of the data I have:

<table border="0" cellpadding="0" cellspacing="0" width="169"><col style="width: 56pt;" width="74"> <col style="width: 71pt;" width="95"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; width: 56pt;" align="center" height="20" width="74">AveWind Direction</td> <td class="xl64" style="width: 71pt;" align="center" width="95">Ave Wind Speed</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">0</td> <td class="xl66" align="center">1.20</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">0</td> <td class="xl66" align="center">3.98</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">0</td> <td class="xl66" align="center">6.46</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">1</td> <td class="xl66" align="center">0.52</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">1</td> <td class="xl66" align="center">2.72</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">1</td> <td class="xl66" align="center">1.47</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">1</td> <td class="xl66" align="center">3.90</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">1</td> <td class="xl66" align="center">1.29</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">2</td> <td class="xl66" align="center">1.41</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">2</td> <td class="xl66" align="center">0.39</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">2</td> <td class="xl66" align="center">8.03</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">3</td> <td class="xl66" align="center">1.75</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">3</td> <td class="xl66" align="center">6.73</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">4</td> <td class="xl66" align="center">0.52</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">4</td> <td class="xl66" align="center">0.79</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">4</td> <td class="xl66" align="center">1.04</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">4</td> <td class="xl66" align="center">0.64</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">4</td> <td class="xl66" align="center">1.28</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">4</td> <td class="xl66" align="center">0.95</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">4</td> <td class="xl66" align="center">0.42</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">5</td> <td class="xl66" align="center">1.18</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">5</td> <td class="xl66" align="center">2.83</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">5</td> <td class="xl66" align="center">5.50</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">5
...
</td> <td class="xl66" align="center">2.89
...
</td> </tr> </tbody></table>
What I want to do is have all the data sorted into categories, like this:

<table border="0" cellpadding="0" cellspacing="0" width="384"><col style="width: 48pt;" width="64"> <col style="width: 48pt;" span="5" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; width: 48pt;" align="center" height="20" width="64">0</td> <td class="xl65" style="width: 48pt;" align="center" width="64">1</td> <td class="xl65" style="width: 48pt;" align="center" width="64">2</td> <td class="xl65" style="width: 48pt;" align="center" width="64">3</td> <td class="xl65" style="width: 48pt;" align="center" width="64">4</td> <td class="xl65" style="width: 48pt;" align="center" width="64">5</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt;" align="center" height="20">1.20</td> <td class="xl66" align="center">0.52</td> <td class="xl66" align="center">1.41</td> <td class="xl66" align="center">1.75</td> <td class="xl66" align="center">0.52</td> <td class="xl66" align="center">1.18</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt;" align="center" height="20">3.98</td> <td class="xl66" align="center">2.72</td> <td class="xl66" align="center">0.39</td> <td class="xl66" align="center">6.73</td> <td class="xl66" align="center">0.79</td> <td class="xl66" align="center">2.83</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt;" align="center" height="20">6.46</td> <td class="xl66" align="center">1.47</td> <td class="xl66" align="center">8.03</td> <td class="xl65" align="center">
</td> <td class="xl66" align="center">1.04</td> <td class="xl66" align="center">5.50</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">
</td> <td class="xl66" align="center">3.90</td> <td class="xl65" align="center">
</td> <td class="xl65" align="center">
</td> <td class="xl66" align="center">0.64</td> <td class="xl66" align="center">2.89</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">
</td> <td class="xl66" align="center">1.29</td> <td class="xl65" align="center">
</td> <td class="xl65" align="center">
</td> <td class="xl66" align="center">1.28</td> <td class="xl65" align="center">
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">
</td> <td class="xl65" align="center">
</td> <td class="xl65" align="center">
</td> <td class="xl65" align="center">
</td> <td class="xl66" align="center">0.95</td> <td class="xl65" align="center">
</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" align="center" height="20">
</td> <td class="xl65" align="center">
</td> <td class="xl65" align="center">
</td> <td class="xl65" align="center">
</td> <td class="xl66" align="center">0.42</td> <td class="xl65" align="center">
</td> </tr> </tbody></table>
Please note that I have a lot of data (over 4000 rows) and it would be impractical for me to do this manually like I have here. I think I have to use a vlookup function however I am very unsure on how to do this. Any help would be greatly appreciated. Oh and I'm no computer programmer so it may have to be in dummy talk :cool:
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try this. Press ALT + F11 to open the Visual Basic Editor, select Module from the Insert menu and paste in

Code:
Sub Separate()
Dim LastRow As Long, i As Long, iStart As Long, iEnd As Long, j As Long
Application.ScreenUpdating = False
j = 2
With ActiveSheet
    LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
    iStart = 2
    For i = 2 To LastRow
        If .Range("A" & i).Value <> .Range("A" & i + 1).Value Then
            iEnd = i
            j = j + 1
            .Cells(1, j).Value = Range("A" & iStart).Value
            .Range(.Cells(iStart, 2), .Cells(iEnd, 2)).Copy Destination:=.Cells(2, j)
            iStart = iEnd + 1
        End If
    Next i
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

Press ALT + Q to close the code window, press ALT + F8, click on Separate then click the Run button.
 
Upvote 0
All I can say is wow....thanks a lot. Makes me feel a lot better that it required code and not just my elementary excel skills.

:rofl:
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top