Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default automatically sorting a simple list

This seems like it should be simple, but I'm not having luck figuring out how
to do it. Any help would be appreciated. I have a simple list of 10 things
each with a value associated with it. As the values change, I'd like the
list to automatically resort itself in ascending order. I don't want to have
to go and highlight the two columns and use the sort command every time I
change one of the values. This should be easy right??? help.
--
Thanks, CBguy
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default automatically sorting a simple list

Right-click on w/sheet tab (where your data is) "View code", and copy/paste
code below. If Column B .. no check for rows ...is changed, it sorts (by
column B) values.

HTH



Sub Worksheet_Change(ByVal target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False

If target.Column < 2 Then Exit Sub

Columns("A:B").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ws_exit:
Application.EnableEvents = True

End Sub

"cbguy" wrote:

This seems like it should be simple, but I'm not having luck figuring out how
to do it. Any help would be appreciated. I have a simple list of 10 things
each with a value associated with it. As the values change, I'd like the
list to automatically resort itself in ascending order. I don't want to have
to go and highlight the two columns and use the sort command every time I
change one of the values. This should be easy right??? help.
--
Thanks, CBguy

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default automatically sorting a simple list

Hey, that works great. Thanks for the help. : )
--
Thanks, CBguy


"Toppers" wrote:

Right-click on w/sheet tab (where your data is) "View code", and copy/paste
code below. If Column B .. no check for rows ...is changed, it sorts (by
column B) values.

HTH



Sub Worksheet_Change(ByVal target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False

If target.Column < 2 Then Exit Sub

Columns("A:B").Select
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ws_exit:
Application.EnableEvents = True

End Sub

"cbguy" wrote:

This seems like it should be simple, but I'm not having luck figuring out how
to do it. Any help would be appreciated. I have a simple list of 10 things
each with a value associated with it. As the values change, I'd like the
list to automatically resort itself in ascending order. I don't want to have
to go and highlight the two columns and use the sort command every time I
change one of the values. This should be easy right??? help.
--
Thanks, CBguy

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
Data sorting automatically? Tommy[_2_] Excel Worksheet Functions 10 March 24th 07 10:09 PM
sorting a dropdown list automatically mohammed Excel Worksheet Functions 3 December 26th 06 01:58 AM
Sorting Data Automatically Sabunabu Excel Worksheet Functions 2 January 4th 06 08:39 PM
Sorting data automatically Graham Mason Excel Worksheet Functions 2 May 21st 05 09:45 PM
sorting automatically Mike Lemke Excel Worksheet Functions 2 October 31st 04 06:51 PM


All times are GMT +1. The time now is 02:41 AM.

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

About Us

"It's about Microsoft Excel"