how do i get columns in Excell to auto-adjust

J

jasonprouse

I want to be able to add an option of adjusting a spreadsheet in Excel 2003by
clicking on an arrow at the top of each column that will change the entire
sheet to fit the requested order of that specific column. For example: i have
a column in my spreadsheet that contains 5 different vendors; I have 75 rows
in this column. I want to be able to add an arrow box at the top of the
column to arrange the entire spreadsheet according to the alphabetical order
of this one column
 
O

Otto Moehrbach

Jason
I don't know what you mean by this "arrow" thing. The following macro
will sort the entire range by the column you choose. You choose the column
by clicking on the header of that column. That's all that you have to do.
I assumed that row 1 is the header row, that your data goes as far down as
Column A does, and that your data is 9 columns wide. Change these things as
needed. HTH Otto
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rColA As Range
If Target.Count > 1 Then Exit Sub
If Target.Row = 1 Then
If Target.Column > Cells(1, Columns.Count).End(xlToLeft).Column Then
_
Exit Sub
Set rColA = Range("A1", Range("A" & Rows.Count).End(xlUp))
rColA.Resize(, 9).Sort Key1:=Cells(2, Target.Column), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub
 
G

Gord Dibben

Select all columns in your range to sort.

Then Data>Sort on the column of vendors.


Gord Dibben MS Excel MVP
 
G

Glenn

jasonprouse said:
I want to be able to add an option of adjusting a spreadsheet in Excel 2003by
clicking on an arrow at the top of each column that will change the entire
sheet to fit the requested order of that specific column. For example: i have
a column in my spreadsheet that contains 5 different vendors; I have 75 rows
in this column. I want to be able to add an arrow box at the top of the
column to arrange the entire spreadsheet according to the alphabetical order
of this one column

Could an AutoFilter be what you are looking for?
 

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