Sort Column Script

B

Bernie

I need to have a script in Excel that would allow the sorting of
columns from column "D" to the column before the last column with data.
I do not want the last column sorted. The criteria for the sort is in
row 1 (Name of an employee). Additional columns will be inserted
between column "D" and the last column so they need to be sorted. I
hope this is clear. Can someone please assist me? Thank you!

Bernie
 
B

Bernie Deitrick

Bernie

How can someone named Bernie NOT know how to do this? ;-)

Sub BernieSort()
Range(Range(Range("D1"), Range("D1").End(xlDown)), _
Range("D1").End(xlToRight)(1, 0)).Sort _
Key1:=Range("D1"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End Sub

HTH,
Bernie
MS Excel MVP
 
B

Bernie

LOL, that's because this Bernie is not a genius and you are.

It works perfectly, thank you so much for the help.

Bernie
 
B

Bernie Deitrick

Bernie,

Glad to hear that it worked OK for you. We all have to start with _zero_
experience - soem of us have just been around longer than others....

Bernie
 

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

Top