A sorting alternative:
Code:
Sub snb()
sn = Split("C,F,A,G,B,J,E,D,I,H", ",")
For j = 0 To UBound(sn)
sn(j) = Columns(sn(j)).Column
Next
Cells(1).CurrentRegion.Rows(1).Offset(Cells(1).CurrentRegion.Rows.Count) = sn
With Cells(1).CurrentRegion
.Sort Cells(.Rows.Count, 1), , , , , , , , , , xlSortRows
.Rows(.Rows.Count).ClearContents
End With
End Sub
or if the number of columns doesn't exceed the alphabet:
Code:
Sub snb_002()
Cells(1).CurrentRegion.Offset(10) = Application.Index(Cells(1).CurrentRegion, Evaluate("Row(" & Cells(1).CurrentRegion.Address & ")"), [transpose(code(mid("CFAGBJEDIH",row(1:10),1))-64)])
end sub
Bookmarks