S
simon
I have created a collection of values from my worksheet using John
Walkenback's cited NoDupes method as below:
Set Allcells _
= Intersect(Range("B:M"),
Range("B3,B6,B9,B12,B15,B18,B21,B24").EntireRow)
On Error Resume Next
For Each cell In Allcells
If cell.Value = "" Then
'do nothing
Else
NoDupes.Add cell.Value, CStr(cell.Value)
End If
Next cell
'Sort the collection
For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) > NoDupes(j) Then
swap1 = NoDupes(i)
swap2 = NoDupes(j)
NoDupes.Add swap1, before:=j
NoDupes.Add swap2, before:=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i
The collection is then copied into another worksheet. However the
collection is sorting the items in the list correctly, but not in
numerical order. For example I have the following:
DNA_1
DNA_2
DNA_3
DNA_10
DNA_11
the sort collection codes puts them in the following order
DNA_1
DNA_10
DNA_11
DNA_2
DNA_3
where I want them to be in numerical order. i.e. DNA_1,DNA_2,DNA_3,
etc.
Can anyone guide me on how I can achieve this please?
Walkenback's cited NoDupes method as below:
Set Allcells _
= Intersect(Range("B:M"),
Range("B3,B6,B9,B12,B15,B18,B21,B24").EntireRow)
On Error Resume Next
For Each cell In Allcells
If cell.Value = "" Then
'do nothing
Else
NoDupes.Add cell.Value, CStr(cell.Value)
End If
Next cell
'Sort the collection
For i = 1 To NoDupes.Count - 1
For j = i + 1 To NoDupes.Count
If NoDupes(i) > NoDupes(j) Then
swap1 = NoDupes(i)
swap2 = NoDupes(j)
NoDupes.Add swap1, before:=j
NoDupes.Add swap2, before:=i
NoDupes.Remove i + 1
NoDupes.Remove j + 1
End If
Next j
Next i
The collection is then copied into another worksheet. However the
collection is sorting the items in the list correctly, but not in
numerical order. For example I have the following:
DNA_1
DNA_2
DNA_3
DNA_10
DNA_11
the sort collection codes puts them in the following order
DNA_1
DNA_10
DNA_11
DNA_2
DNA_3
where I want them to be in numerical order. i.e. DNA_1,DNA_2,DNA_3,
etc.
Can anyone guide me on how I can achieve this please?