#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default auto sort


Hi all,

Suppose my range A1 to A7 contains following numbers:
before sort After Sort
---------- ----------
7 1
5 2
2 4
8 5
6 6
4 7
1 8
-- If I change 8 as 3 then it should be automatically sorted,
and expected list should be 1 to 7...is it possible?
please.


--
jamex
------------------------------------------------------------------------
jamex's Profile: http://www.excelforum.com/member.php...o&userid=32243
View this thread: http://www.excelforum.com/showthread...hreadid=547434

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default auto sort

Hi
Assuming your numbers are in A1 to A7 on Sheet 1. Then put this code in
the code module behind sheet 1:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim ChangeCell as Range
Set ChangeCell = Intersect(Target, Range("A1:A7"))
If Not ChangeCell Is Nothing Then
Range("A1:A7").Sort Key1:=Range("A1"), Order1:=xlAscending
End If
End Sub

To get to that code module, click Alt+F11 to open the VB Editor then
double click the reference to Sheet1. Paste in the above code.

regards
Paul


jamex wrote:
Hi all,

Suppose my range A1 to A7 contains following numbers:
before sort After Sort
---------- ----------
7 1
5 2
2 4
8 5
6 6
4 7
1 8
-- If I change 8 as 3 then it should be automatically sorted,
and expected list should be 1 to 7...is it possible?
please.


--
jamex
------------------------------------------------------------------------
jamex's Profile: http://www.excelforum.com/member.php...o&userid=32243
View this thread: http://www.excelforum.com/showthread...hreadid=547434


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default auto sort


Thanks to all , really excellent Mike and all friends

Cheer,
Jamex


--
jamex
------------------------------------------------------------------------
jamex's Profile: http://www.excelforum.com/member.php...o&userid=32243
View this thread: http://www.excelforum.com/showthread...hreadid=547434

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default auto sort


I hope this helps, add this in the sheet that you need your data sorted.
Just in case you are not familiar with it, go to _T_ools, _M_acro,
_V_isual Basic Editor (Or you can just press Alt-F11). Under VBA
Project, select the sheet your data is in and enter the following:

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A1:A7")) Is Nothing Then

Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal

End If

End Sub


--
Bearacade
------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=547434

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default auto sort

This is probably not the best way, but one way...

Right click on worksheet tab
Select "View Code"
Change (General) to Worksheet
Now enter the following Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Columns("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, _
Header:=xlGuess,OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End Sub
--
Mike Q.


"jamex" wrote:


Hi all,

Suppose my range A1 to A7 contains following numbers:
before sort After Sort
---------- ----------
7 1
5 2
2 4
8 5
6 6
4 7
1 8
-- If I change 8 as 3 then it should be automatically sorted,
and expected list should be 1 to 7...is it possible?
please.


--
jamex
------------------------------------------------------------------------
jamex's Profile: http://www.excelforum.com/member.php...o&userid=32243
View this thread: http://www.excelforum.com/showthread...hreadid=547434




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
Is there a way to Auto sort or save a sort? Barbie Excel Discussion (Misc queries) 11 December 1st 09 09:48 PM
Auto-Sort Won't Sort All Column Cells TikiTembo Excel Discussion (Misc queries) 1 March 25th 08 07:00 PM
Last one for the day! Auto sort. loc Setting up and Configuration of Excel 3 May 22nd 07 07:22 PM
Auto sort A[_2_] Excel Programming 1 March 29th 06 11:13 PM
auto sort mharris Excel Programming 1 January 27th 04 09:04 PM


All times are GMT +1. The time now is 07:23 AM.

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"