Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Sorting
How do I sort:
101 120 103 4 1 2 15 12 26 into: 1 2 4 12 15 26 101 103 120 Bruno |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Sorting
Hi Bruno,
Am Mon, 15 Jun 2015 18:20:48 +0200 schrieb Bruno Campanini: How do I sort: 101 120 103 4 1 2 15 12 26 into: 1 2 4 12 15 26 101 103 120 try: Sub Sort() Dim LRow As Long, i As Long With Sheets("Sheet1") LRow = .Cells(Rows.Count, 1).End(xlUp).Row .Sort.SortFields.Clear .Range("A1:C" & LRow).Sort Key1:=.Range("A1"), order1:=xlAscending, Header:=xlNo For i = 1 To LRow .Sort.SortFields.Clear .Sort.SortFields.Add Key:=.Cells(i, 1), _ SortOn:=xlSortOnValues, Order:=xlAscending With .Sort .SetRange Rows(i) .Header = xlNo .Orientation = xlLeftToRight .Apply End With Next End With End Sub Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Sorting
Claus Busch explained :
Hi Bruno, Am Mon, 15 Jun 2015 18:20:48 +0200 schrieb Bruno Campanini: How do I sort: 101 120 103 4 1 2 15 12 26 into: 1 2 4 12 15 26 101 103 120 try: Sub Sort() Dim LRow As Long, i As Long With Sheets("Sheet1") LRow = .Cells(Rows.Count, 1).End(xlUp).Row .Sort.SortFields.Clear .Range("A1:C" & LRow).Sort Key1:=.Range("A1"), order1:=xlAscending, Header:=xlNo For i = 1 To LRow .Sort.SortFields.Clear .Sort.SortFields.Add Key:=.Cells(i, 1), _ SortOn:=xlSortOnValues, Order:=xlAscending With .Sort .SetRange Rows(i) .Header = xlNo .Orientation = xlLeftToRight .Apply End With Next End With End Sub Regards Claus B. Ok, thank you. But let me say I was not very precise in my question: I intended to get the result with SORT method + its proper parameters, without coding a time-consuming range scanning. Bruno |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SORTING DATA IN TWO COLUMNS (salary and name ) - sorting as perdescending order of salary | Excel Programming | |||
Sorting Values Without Sorting Formulas | Excel Discussion (Misc queries) | |||
Automatic sorting (giving max and min) based on custom sorting lis | Excel Worksheet Functions | |||
Sorting VLookup vs Sorting SumProduct | Excel Discussion (Misc queries) | |||
Sorting ListBox results or transposing ListBox values to other cells for sorting | Excel Programming |