Sort Columns

  • Thread starter Thread starter T De Villiers
  • Start date Start date
T

T De Villiers

Hi,

I have 6 columns and 5000 rows.
My headings are:
a,b,c,d,e,f

I need to write a macro which sorts the cols in order:
a,c,d,b,e,f

It does need to be a macro, as opposed to manually doing a custom
list.
I have tried writing a macro which involves custom lists (below)
but doesnt quite work.

Thanks


Sub sortcol()

Range("A1:G12936").Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=6, MatchCase:=False,
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub
 
Sub sortcol()

Range("A1:G12936").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Key2:=Range("C1"), Order2:=xlAscending, _
Key3:=Range("D1"), Order3:=xlAscending, _
Header:=xlGuess, _
MatchCase:=False, _
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
Range("A1:G12936").Sort Key1:=Range("B1"), Order1:=xlAscending, _
Key2:=Range("E1"), Order2:=xlAscending, _
Key3:=Range("F1"), Order3:=xlAscending, _
Header:=xlGuess, _
MatchCase:=False, _
Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top