So I found a sorting property to arrange numbers numerically but I have messed up something simple in the code
here is the website I got it from any way i could get a close fix
Sort Numbers in Excel VBA - Easy Excel Macros
Here is the code I got from is im missing something simple any ideas thanks guys
Code:Sub start()Code:Dim i As Integer, j As Integer, temp As Integer, rng As Range Set rng = Range("A1").CurrentRegion For i = 1 To rng.Count For j = i + 1 To rng.Count If rng.Cells(j) < rng.Cells(i) Then End If 'swap numbers temp = rng.Cells(i) rng.Cells(i) = rng.Cells(j) rng.Cells(j) = temp Next j Next i End sub
Last edited by Bob Phillips; 2014-06-20 at 09:19 AM. Reason: Added VBA tags
That article was badly written, it didn't explain that you needed to insert the swap code betweenm the If ... EndIf
Code:Sub start() Dim i As Integer, j As Integer, temp As Integer, rng As Range Set rng = Range("A1").CurrentRegion For i = 1 To rng.Count For j = i + 1 To rng.Count If rng.Cells(j) < rng.Cells(i) Then 'swap numbers temp = rng.Cells(i) rng.Cells(i) = rng.Cells(j) rng.Cells(j) = temp End If Next j Next i End Sub
Bookmarks