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
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:
[COLOR=#333333]Dim i As Integer, j As Integer, temp As Integer, rng As Range[/COLOR]
[COLOR=#333333]
Set rng = Range("A1").CurrentRegion[/COLOR]
[COLOR=#333333] For i = 1 To rng.Count[/COLOR]
[COLOR=#333333] For j = i + 1 To rng.Count[/COLOR]
[COLOR=#333333] If rng.Cells(j) < rng.Cells(i) Then[/COLOR]
[COLOR=#333333] End If[/COLOR]
[COLOR=#333333] 'swap numbers[/COLOR]
[COLOR=#333333] temp = rng.Cells(i)[/COLOR]
[COLOR=#333333] rng.Cells(i) = rng.Cells(j)[/COLOR]
[COLOR=#333333] rng.Cells(j) = temp[/COLOR]
[COLOR=#333333] Next j[/COLOR]
[COLOR=#333333] Next i[/COLOR]
[COLOR=#333333]End sub[/COLOR]
Last edited by a moderator: