Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I got an answer on this but maybe I missed something. The field values from
Access db are strings but they are the department ID numbers. Also the statusID is a number 1...4. Someone helpfully said to coerce it to a number by adding columns(1)=columns(1) to the macro. I tried this and I also tried columns(16)= columns(16) becuase that is the first sort key. It still sorts the numbers as text, 1 1000 2 etc. What did I do wrong, or how do I coerce the values in fields #16 and 19 to numbers? thanks, Sub Sort() 'finds the number of the last column 'Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, .cells(1, columns.count).end(xlToLeft)).End(xlUp)) ' ' Sorts by Item Name, Dept, Status# Macro Dim rng As Range ' sorts on Dept, & Status since there is only 3 keys available in a sort With ActiveSheet Columns(16).Value = Columns(16).Value Set rng = .Range(.Cells(1, 1), .Cells(Rows.Count, 26).End(xlUp)) MsgBox rng.Address rng.Sort key1:=.Cells(1, 16), Order1:=xlAscending, _ key2:=.Cells(1, 19), Order2:=xlAscending, _ key3:=.Cells(1, 3), Order3:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how can I sort a column numerically with both words and numbers i. | Excel Discussion (Misc queries) | |||
sort doesn't sort numerically | Excel Programming | |||
how do i sort a column numerically going from 01-01 to 225-99 | Excel Worksheet Functions | |||
Pls. reply Sort Data and copy to next coulmn when sort order chang | Excel Programming | |||
Sort Numerically Worksheets via VB when creating a new worksheets | Excel Programming |