Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I auto-sort in Excel?

Status
Not open for further replies.

tomswaelen

Technical User
Mar 12, 2007
3
BE
I have a worksheet in Excel which contains scores for a quiz I am organizing. The rows contain the team names, the columns the scores per round per team.
I would like to have the worksheet automatically sort the columns in descending order (so that the winner will come out on top after the quiz has finished), everytime I change something (everytime a score is updated). I can't find anything in Excel which would allow me to do that, so I'm guessing it's only possible in VBA? Unfortunately, I don't know anything about VBA, so I'm stuck.

These are the ranges I would like to have sorted, in order of priority:

Row 1 is the row with the column titles (Round 1, Round 2,...).
C2: C26
N2:N26
M2:M26
L2:L26
K2:K26
J2:J26
I2:I26
H2:H26
G2:G26
F2:F26
E2:E26
D2:D26

Can anyone help me? I need to be taken through this step-by-step, as I know literally nothing about VBA...
 
I know literally nothing about VBA
So, the macrorecorder and the F1/F2 keys are your best friends.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I know exactly how to record a macro, and that would work fine, if only I could have that macro execute each time something in the worksheet changes.
 
Have a look at the Change event procedure of your Worksheet.
Tip: you're likely to consider the Application.EnableEvents property if you change anything in the sheet within thi procedure.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Did you not read my first post? :)

Like I said, I know absolutely nothing about VBA, so your last post makes no sense at all to me...
 
Just figured this out myself.

Record the macro to sort your column.

View the code for the desired worksheet.

Add:

Private Sub Worksheet_Activate()
Copy and paste "Your Macro"
End Sub

Here is my worksheet:

Private Sub Worksheet_Activate()
Columns("D:O").Select
Selection.Sort Key1:=Range("H2"), Order1:=xlDescending, Key2:=Range("D2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Range("A1").Select
End Sub


 



Activate does not necessarily Calculate.

Just SheetObject.Calculate

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top