Hello Everyone
I am studying the VBA and looking for this code about sort number .I think so much but did not understand .maybe i am stupid!
.............
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
..........
i did understand this code : rng.cells(j)=temp .
why not use temp=rnd.cell(j) and what ' different ?
Please explain
Thanks.
I am studying the VBA and looking for this code about sort number .I think so much but did not understand .maybe i am stupid!
.............
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
..........
i did understand this code : rng.cells(j)=temp .
why not use temp=rnd.cell(j) and what ' different ?
Please explain
Thanks.