i have a column that contains in some cells numbers and in some cells letters

WOODY_GOODWOOD

New Member
Joined
Apr 12, 2013
Messages
4
what i would like to do is when i do sorting the cells that contains letters go to the bottom leaving the cells that contains numbers on the top.
this is the code i use:

Range("A3:E20").Select
Selection.Sort Key1:=Range("E3"), Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("I12").Select

DQ
DNS
80,00
32,10
32,00
31,51
31,50
03,00

<colgroup><col></colgroup><tbody>
</tbody>
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Code:
Range("A3:E20").Sort Key1:=Range("E3"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
[COLOR=#ff0000]DataOption1:=xlSortOnValues[/COLOR]
Range("I12").Select
 
Upvote 0
Sorry did you change Order1:=xlAscending ?

I forgot to highlight
 
Upvote 0
If i put Order1:=xlAscending then the numbers will Ascend also. I need the bigger number on the top. That is why i used the Descending in the first code. I'm sorry for haven't made it clear.
 
Upvote 0
Sorry for delayed reply.

Range E20 may vary ? How would you address this issue ? Or is standard ?

Below code you can test it in test workbook.

Code:
Sub Please_Test_In_TestWorkbook()
Dim Rng As Range
Dim sAddr As String


Range("A3:E20").Sort Key1:=Range("E3"), Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortOnValues


For Each Rng In Range("E3:E20")
   If Not Rng.Value Like "*[!A-Za-z]*" Then
      sAddr = Rng.Address
   End If
Next Rng


If sAddr <> "" Then
   Range("A3:" & sAddr).Cut
   Range("A21").Insert Shift:=xlDown
End If


Range("I12").Select


End Sub
 
Upvote 0
Goodmorning!!!
I tested but it doesn't work! It looks like the rest of the code (after the sorting) is not working. Still the "DQ" and the "DNS" are on the top after the sorting.
the range E3:E20 is standard
Thank you in advance for your effort!
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,257
Members
448,880
Latest member
aveternik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top