If you've got your original data in column A starting at A2 and going to say A560 and you want it sorted then distributed in bunches of 40 rows across the 15 columns fmo A to N try this
Sub sortanddistribute()
Dim rngarea As Range
Set rngarea = ActiveSheet.Range("a2:a560")
rngarea.Select
ActiveWorkbook.Worksheets("Sheet1").sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").sort.SortFields.Add Key:=Range("A2:A560") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").sort
.SetRange Range("A2:A560")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
columnnum = 0
For rownum = 2 To 560 Step 40
Range("A" & rownum & ":" & "A" & rownum + 39).Select
Selection.Cut
Range("a2").Offset(0, columnnum).Select
ActiveSheet.Paste
columnnum = columnnum + 1
Next rownum
End Sub
Otherwise put your spreadsheet up with teh original data and your proposed solution so we can see how you want the data reordered
Bookmarks