sorting

C

cgables

I want to sort a column & have the rows reorder automatically instead o
just the column
 
A

AlfD

Hi!

Select the whole of the data area you want to sort.
Then use Data>Sort using the key column(s) you want to sort by. Th
rest of the data in the rows will move accordingly.

Al
 
D

David McRitchie

Hi ...,
For most usage you can simply use Ctrl+A to select all cells
on the sheet. If you have separate areas; obviously that would
not be the way to start. The sort has something to help you
(we're from the Gov't and we're here to you, type of logic).

If you select a single cell before invoking the sort, the sort
will assume you meant to expand to the current region.
You can test that with Ctrl+* (asterisk), of course if
you select a column only that column will be included in
the sort -- either way you probably don't get what you
really want (but it could be, and so it is useful).

Select the current region around the active cell (the current region is
a data area enclosed by blank rows and blank columns)
 
C

cgables

Thank you, that works. But is there a way to have it sort automaticall
as I add numbers in the sort column so that I don't have to highligh
all the rows
 
D

David McRitchie

HI "cgables >" <[email protected],
You could use an event macro each time you change a cell, but
that that would drive you crazy when things move around, as you
attempt to make an entry into the next cell.

A better choice would probably be to sort the sheet when the
worksheet is activated.
Event Macros, Worksheet Events and Workbook Events
http://www.mvps.org/dmcritchie/excel/event.htm

To install a worksheet event macro
http://www.mvps.org/dmcritchie/excel/event.htm#blueboxWS

Record a macro to get an idea of what you want for your sort,
the following is an example that might work for you.
It sorts on Column A ascending and Column B ascending.
The headers in Row 1 are not sorted..

Option Explicit
Private Sub Worksheet_Activate()
Cells.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("B2") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom
End Sub

We are a friendly bunch here, in the Excel newsgroups, and it's a lot more
friendly and professional to use your first and last name when posting, so
we know who we are talking to. If ExcelForum does not make that easy
then please include your first and last name in your signature line.
 
C

cgables

Thanks for the help. I am not very experienced in Excel so I will us
the highlighting and sort method. Thanks again for the help.
Cindy Dorre
 
D

David McRitchie

Hi Cindy,
Thanks for the feedback, even if is that you don't want
to use macros yet. I'd not be able to do much without them.

Here is a simple manual way to sort on Column A.
Normally I'd say stay clear of using the ascending/descending
toolbar buttons because you can mess up your data with them.
But as long as you select all cells on the worksheet beforehand
the data in the rows will move with the sorted column.

Select a cell in Column A (the one and only column to be sorted)
use Ctrl+A to select all cells, your active cell is still your active cell.
click on the sort ascending toolbar button.

There is one thing that can go wrong even if you follow this
carefully and that is the Excel is going to determine if you have
a header row or not. So to help Excel see that, make your
header row bold and perhaps center some of the items.

HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm
 
C

cgables

David:

Thanks for the help. I have been practicing, and I think I have i
now. I will definately be back with more questions as I progress t
bigger and better things in Excel.

Thank you again
Cindy Dorre
 
Top