Sorting Question

R

RJQMAN

I would like to read data on one page, automatically sort it, and print
it on another worksheet in the same workbook without changing the data
on the original page. This is information for an announcer at a
sporting event, and I do not want the announcer to have to do manual
excel operations, but I could use a button for a VB sort if I had to.
I would prefer not to.

Here is the scenario. I have several columns of data on the second
worksheet in a workbook. The data is in columns C, Column D, Column Y,
and column Z. The data in each of these columns has been calculated
from data entered manually at the sporting event into the first
worksheet in the workbook.

I need to take these four columns of data from the second page to the
third page of the workbook, and display it in sorted order, with the
sorting based on the numeric data in column Z. Then I need to take it
to the fourth page, and display it sorted based on the numeric data in
column AA.

Here is an example of the way the data is displayed on the 2nd
Worksheet;

Column C Column D Column Y Column Z ColumnAA

GROUP NAME SCORE RANK IN GROUP OVERALL RANK

Group A Jones 22.5 6 8
Group A Smith 22.9 5 7
Group A Kelly 50 2 2
Group A Brown 44 4 4
Group A White 50 2 2
Group A Scarlet 65 1 1
Group B Tommy 33 2 6
Group B Jane 44 1 4

Here is how I would like to have it displayed on the third worksheet -
sorted by group and then by rank in the group. When there is a tie, I
do not care which name comes first.

GROUP NAME SCORE RANK IN GROUP

Group A Scarlett 65 1
Group A White 50 2
Group A Kelly 50 2
Group A Brown 44 4
Group A Smith 22.9 5
Group A Jones 22.5 6

Group B Jane 44 1
Group B Tommy 33 2


I would also like to have it displayed on the 4th worksheet like this;

NAME SCORE OVERALL RANK

Scarlett 65 1
White 50 2
Kelly 50 2
Brown 44 4
Jane 44 4
Tommy 33 6
Smith 22.9 7
Jones 22.5 8

Once again, when there is a tie, I do not care which name is first. I
know there is a way to do this, but I need help. I am a beginner at
best, but I am learning. Can anyone help me with the code?

Thanks in advance.
 
B

Bob Phillips

Sub CopyAndSort()
Worksheets("Sheet2").Cells.Copy
Worksheets("Sheet3").Select
ActiveSheet.Paste
Columns("C:G").Sort Key1:=Range("F2"), _
Order1:=xlAscending, _
Header:=xlYes
Columns("G:G").ClearContents
Columns("A:B").Delete
Range("A1").Select

Worksheets("Sheet2").Cells.Copy
Worksheets("Sheet4").Select
ActiveSheet.Paste
Columns("C:G").Sort Key1:=Range("F2"), _
Order1:=xlAscending, _
Header:=xlYes
Columns("G:G").ClearContents
Columns("A:C").Delete
Range("A1").Select
End Sub
 
R

RJQMAN

Thank you for replying so quickly. It is 5 AM here and I have been up
all night working on this (that's a lot for a 60 year old dude). I
loaded your code, and the program stops dead at the word 'Paste',
giving a message that the copy area and the paste area are not the same
size. I admit I do not understand the code, so I am struggling to
resolve it.

My data is in columns C,D,Y,Z, and AA on sheet 2. I want to place it
in any 3 colums on sheet 3 and any 3 columns on sheet 4. I do not
understand the references to C:G and the Range ("F2") _

If I understood more, I could probably figure it out myself, but I do
not know what these mean. I appreciate your patience and I appreciate
your help.
 
R

RJQMAN

OK - I think I figured it out. Between the textbook I am using and
your help, it is now working. Thank you.

Bob Q - Florida
 

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