Hello
I need help with a script that sorts column C to BC in ascending order.
First Column C in ascending order. Then sort column D in ascending order. Then E and so on. Until column BC is sorted in ascending order.
I recorded the procedure but I think there may be simple loop to code instead which loops from one column til the last one. Is it possible?
Here is the code I have so far.
Sub sort()
'
' sort Makro
'
'
Range("A8:BC360").Select
ActiveWorkbook.Worksheets("Årsschema").sort.SortFields.Clear
ActiveWorkbook.Worksheets("Årsschema").sort.SortFields.Add2 Key:=Range( _
"C8:C360"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Årsschema").sort.SortFields.Add2 Key:=Range( _
"D8:D360"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Årsschema").sort.SortFields.Add2 Key:=Range( _
"E8:E360"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Årsschema").sort.SortFields.Add2 Key:=Range( _
"F8:F360"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Årsschema").sort
.SetRange Range("A8:BC360")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B8").Select
End Sub
/Anders
Bookmarks