Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 33
Default automatic sorting

I have many columns of corresponding data, i was wondering if there was a way
to not only sort one column but have the coresponding data in other columns
sort with it. I need an automatic sort beacause the data is to be refreshed
frequently and the actual sort a list comand is not reasonable. If anyone
could help it would be much apreciated, i am co-op and could use all the help
i can get.

Thank you
--

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default automatic sorting

Try this 'event code' (must right-click the tab of the SS that you are
running it on, select 'view code' and paste it into the window that opens up).
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim EndData As Long

If Target.Column < 2 Then Exit Sub

Application.ScreenUpdating = False

EndData = Cells(Rows.Count, 1).End(xlUp).Row

With Range(Cells(2, 1), Cells(EndData, 2))
.Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With

Application.ScreenUpdating = False
End Sub
Notice!! You will sort on Column B; change this to suit your needs.


Regards,
Ryan---


--
RyGuy


"bkunes" wrote:

I have many columns of corresponding data, i was wondering if there was a way
to not only sort one column but have the coresponding data in other columns
sort with it. I need an automatic sort beacause the data is to be refreshed
frequently and the actual sort a list comand is not reasonable. If anyone
could help it would be much apreciated, i am co-op and could use all the help
i can get.

Thank you
--

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 33
Default automatic sorting

i am not real familiar with excel and this seams a little to complex. if it
can me simplified or done in an easier way i would appreciate it.
--



"ryguy7272" wrote:

Try this 'event code' (must right-click the tab of the SS that you are
running it on, select 'view code' and paste it into the window that opens up).
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim EndData As Long

If Target.Column < 2 Then Exit Sub

Application.ScreenUpdating = False

EndData = Cells(Rows.Count, 1).End(xlUp).Row

With Range(Cells(2, 1), Cells(EndData, 2))
.Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With

Application.ScreenUpdating = False
End Sub
Notice!! You will sort on Column B; change this to suit your needs.


Regards,
Ryan---


--
RyGuy


"bkunes" wrote:

I have many columns of corresponding data, i was wondering if there was a way
to not only sort one column but have the coresponding data in other columns
sort with it. I need an automatic sort beacause the data is to be refreshed
frequently and the actual sort a list comand is not reasonable. If anyone
could help it would be much apreciated, i am co-op and could use all the help
i can get.

Thank you
--

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default automatic sorting

You said you want the sort done automatically.

There is no other way to make it "automatic" than by using code.

The code is sheet event code.

Right-click on the sheet tab and "View Code".

Copy/paste the amended code into that sheet module.

Alt + q to return to Excel

Enter something into column B and the Column B will sort in ascending order.
The other columns will stay attached to column B.

If you want a different column to sort on, you must edit the code to reflect
that.

If you want to try this code and need editing, post back with some particulars.


Gord

On Tue, 19 Feb 2008 13:04:01 -0800, bkunes
wrote:

i am not real familiar with excel and this seams a little to complex. if it
can me simplified or done in an easier way i would appreciate it.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default automatic sorting

ryguy/bkunes

OP wants to sort all columns together by one column.

The code of Sandy Mann's that you posted will only sort column B but not
automatically include the other columns in the sort.

A change to the code..................

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim EndData As Long

If Target.Column < 2 Then Exit Sub

Application.ScreenUpdating = False

EndData = Cells(Rows.Count, 1).End(xlUp).Row

With ActiveSheet.UsedRange '<-----------change made
.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With

Application.ScreenUpdating = False
End Sub


Gord Dibben MS Excel MVP



On Tue, 19 Feb 2008 12:43:06 -0800, ryguy7272
wrote:

Try this 'event code' (must right-click the tab of the SS that you are
running it on, select 'view code' and paste it into the window that opens up).
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim EndData As Long

If Target.Column < 2 Then Exit Sub

Application.ScreenUpdating = False

EndData = Cells(Rows.Count, 1).End(xlUp).Row

With Range(Cells(2, 1), Cells(EndData, 2))
.Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With

Application.ScreenUpdating = False
End Sub
Notice!! You will sort on Column B; change this to suit your needs.


Regards,
Ryan---




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatic data sorting? Patrick Excel Worksheet Functions 12 February 20th 08 05:01 PM
Automatic sorting [email protected] Excel Worksheet Functions 0 June 26th 07 09:24 PM
Automatic Sorting Blade370 Excel Discussion (Misc queries) 1 March 20th 07 12:20 PM
automatic sorting gmisi Excel Worksheet Functions 3 October 11th 06 11:33 PM
Automatic Sorting????? Bigredno8 Excel Discussion (Misc queries) 3 May 28th 05 11:11 PM


All times are GMT +1. The time now is 01:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"