Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following code is designed to sort an alphanumeric list consisting of
text & one or 2 digits by inserting a leading zero, sorting, and then stripping the zero back, to produce the following results: Pre-sort condition -------------------- AC20 AC1 AC2 AC9 AC10 Normal Excel Sort Result ----------------------------- AC1 AC10 AC2 AC20 AC9 Macro Sort Result --------------------- AC1 AC2 AC9 AC10 AC20 The Selection.Sort line in the following code generates the error €œSort method of Range class failed.€ Does anyone know why? Sub AlphaSort() Dim rng As Range Dim intFirst As Integer Dim intLast As Integer ' Sorts Alphanumeric list by adding then removing leading zeros Call AddLeadingZero intFirst = Selection(1).Row intLast = Selection(Selection.Count).Row Set rng = Range(Cells(intFirst, "B"), Cells(intLast, "F")) rng.Select Selection.Sort 'Code fails here Call RemoveLeadingZero End Sub Thank you. Sprinks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
TABLE ROW SORT ERROR? | Excel Discussion (Misc queries) | |||
vlookup and sort error | Excel Worksheet Functions | |||
Sort error | Excel Discussion (Misc queries) | |||
sort ascending error | Excel Discussion (Misc queries) | |||
Selection.Sort error | Excel Programming |