![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Microsoft Office support MS Office support forum |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 4
OS: XP
|
Can someone help me Auto Sort in Excel?
Hi everyone,
I was wondering if someone can help me autosort a list of data. What I have is the schedule for the upcoming European Cup of Football. so I would like to have the standings auto sorted when people enter their predictions on the sheet... Worksheet 1 has the predictions and on the right it has a blank table for the teams to go there... (Where I want the sorted data to go) Worksheet 2 is just a bunch of formulas worksheet 3 has the standings but not sorted in the table... I would like it sorted by points first, and if their is a tie then sorted by GD (goal differential) any help would be great :) Thank a lot guys
|
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Registered User
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 160
OS: Windows XP SP3
|
Re: Can someone help me Auto Sort in Excel?
Here are some tips that may help you get started. If, for example, you wanted to sort the "Group A" table on the third worksheet in your Excel file, you would select that worksheet, then select the appropriate range (E3:M7 in this example), go to the Excel menu and select Data and then Sort, select the Header row option, sort by Pts descending (or ascending), then by GD descending (or ascending).
If you wanted to perform that same operation using a macro, here's some sample code: Code:
Sub DoSort()
Dim ws As Worksheet
Set ws = Worksheets(3)
ws.Range("E3:M7").Sort Key1:=ws.Range("M3"), Order1:=xlDescending, _
Key2:=ws.Range("L3"), Order2:=xlDescending, Header:=xlYes
End Sub
|
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 4
OS: XP
|
Re: Can someone help me Auto Sort in Excel?
thank you...
is there any way to get it to update without hitting the pay button on the macro? unless i'm doing something wrong here... like how do I get it to autmatically sort without running the macro again? Last edited by progpeps; 05-22-2008 at 10:19 PM. |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 160
OS: Windows XP SP3
|
Re: Can someone help me Auto Sort in Excel?
Excel gives you several ways to automatically perform tasks. You could, for example, set it up to do that sorting subroutine every time someone enters data on the first worksheet. Or you can have it automatically perform the sorting right before the workbook is saved. Or you can have it do the sorting when the workbook is first opened. And, of course, you can have the sorting done when someone clicks on a command button, or when someone presses a keystroke combination, such as Ctrl-e.
First, you should decide how you want to handle the sorting. Do you want it to sort when someone types in a number? Or when someone saves the workbook? You have a number of choices. |
|
|
|
|
|
#6 (permalink) |
|
Registered User
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 160
OS: Windows XP SP3
|
Re: Can someone help me Auto Sort in Excel?
Here's one way to set it up. In Excel, press Alt-F11 to get to the Visual Basic Editor, then Ctrl-R to display the Project Explorer. In the Project Explorer, double-click the object Sheet1 (EC Fixtures) to open the code window. Put in the following code.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Worksheets(1).Range("E9:F32"), Target) Is Nothing) Then
DoSort
End If
End Sub
Private Sub DoSort()
Worksheets(3).Range("E3:M7").Sort Key1:=Worksheets(3).Range("M3"), Order1:=xlDescending, _
Key2:=Worksheets(3).Range("L3"), Order2:=xlDescending, Header:=xlYes
Worksheets(3).Range("E10:M14").Sort Key1:=Worksheets(3).Range("M10"), Order1:=xlDescending, _
Key2:=Worksheets(3).Range("L10"), Order2:=xlDescending, Header:=xlYes
Worksheets(3).Range("E17:M21").Sort Key1:=Worksheets(3).Range("M17"), Order1:=xlDescending, _
Key2:=Worksheets(3).Range("L17"), Order2:=xlDescending, Header:=xlYes
Worksheets(3).Range("E24:M28").Sort Key1:=Worksheets(3).Range("M24"), Order1:=xlDescending, _
Key2:=Worksheets(3).Range("L24"), Order2:=xlDescending, Header:=xlYes
End Sub
Last edited by David M58; 05-23-2008 at 09:52 AM. |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 4
OS: XP
|
Re: Can someone help me Auto Sort in Excel?
thank you so much Dave...
I was trying that other function as well but I was missing the If Not, so it wasn't calling to DoSort function Thank for you help d00d :)!!!!!! |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: Aug 2009
Posts: 1
OS: Vista
|
Re: Can someone help me Auto Sort in Excel?
Great! This thread was of huge help
Mine works too!Thank you big time! PS: Hmm... Now I have to do all those matches and groups
Last edited by KirKanu; 08-29-2009 at 08:07 AM. |
|
|
|
|
|
#10 (permalink) |
|
Registered User
Join Date: Sep 2009
Posts: 1
OS: xp
|
Re: Can someone help me Auto Sort in Excel?
I tried the code above but got this error: "Run-time error '1004: Application-defined or object-defined error". Any suggestions? Here is the code that worked for me in excel 2003, it will not work either:
Private Sub Worksheet_Calculate() Range("A1:C141").Sort _ Key1:=Range("B2"), _ Order1:=xlAscending, _ Key2:=Range("A2"), _ Order2:=xlAscending, _ Header:=xlGuess, _ OrderCustom:=1, _ MatchCase:=False, _ Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal, _ DataOption2:=xlSortNormal End Sub |
|
|
|
![]() |
| Thread Tools | |
|
|