Hi, I am currently using custom sort to sort a big list.
I want to apply the custom sort 39 or n times.
The sorted list contains 40 * 40 cities for a total of 1600 rows + 1 header row.
The list starts with City1 to City40, then it starts over at City2, City1, City3, ..., City40.
City1, City2, City3, City4, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
City2, City1, City3, City4, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
City3, City1, City2, City4, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
City4, City1, City2, City3, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
Edit: In my workbook the city names doesn't contain the numbers after the cities.
I want to apply the custom sort 39 or n times.
Code:
Sub SortCity2()
range("A42:H81").Select
ActiveWorkbook.worksheets("Snabb2").Sort.SortFields.Clear
ActiveWorkbook.worksheets("Snabb2").Sort.SortFields.add key:=range("A42"), SortOn:=xlSortOnValues, _
Order:=xlAscending, CustomOrder:="City2, City1, City3, City4, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40", DataOption:=xlSortNormal
With ActiveWorkbook.worksheets("Snabb2").Sort
.SetRange range("A42:H81")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
The sorted list contains 40 * 40 cities for a total of 1600 rows + 1 header row.
The list starts with City1 to City40, then it starts over at City2, City1, City3, ..., City40.
City1, City2, City3, City4, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
City2, City1, City3, City4, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
City3, City1, City2, City4, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
City4, City1, City2, City3, City5, City6, City7, City8, City9, City10", City11, City12, City13, City14, City15, City16, City17, City18, City19, City20, City21, City22, City23, City24, City25, City26, City27, City28, City29, City30, City31, City32, City33, City34, City35, City36, City37, City38, City39, City40
Edit: In my workbook the city names doesn't contain the numbers after the cities.
Last edited: