Do we have time for yet another Sort problem?

  • Thread starter Thread starter theSquirrel
  • Start date Start date
T

theSquirrel

I have a worksheet with various bits of data (mostly numeric values)
but with some text type characters sparingly used. Below is an
example of the data I am working with:

0
1+x
1
5
1
1
1
2
4
1
3
3(1)
0
0
0
0

Now... if i sort it i end up getting this.
0
0
0
0
0
1
1
1
1
1
2
3
4
5
1+x
3(1)

You will notice that I have 2 values at the bottom that I would like
to see next to their corresponding number instead of sorted as text at
the bottom.

So far I have tried to format the cells containing the values as TEXT,
I have tried to use the DataOption1:=xlSortTextAsNumbers

Here is the code I am using to sort with:

Public Sub SortMain(SortColumnAndRow As String)
Set SortKey = TempList.Range(SortColumnAndRow)

SortRange.Sort Key1:=SortKey, _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

Anyone have any ideas on what I can do?
 
If u have data in A1:A16, and B1:B16 is free
Sub xSort()
For t = 1 To 16
Cells(t, 2) = Val(Cells(t, 1))
Next
Range("A1:B16").Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("B1:B16").Select
Selection.ClearContents
Range("B1").Select
End Sub



"theSquirrel" skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top