#1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default sorting

can i sort my data automatically without click on "sort" icon
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 11,058
Default sorting

You can have a change event macro perform the sort.
--
Gary''s Student - gsnu200800


"abolbashaari" wrote:

can i sort my data automatically without click on "sort" icon

  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,420
Default sorting

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:C" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

Me.Cells.Sort key1:=Me.Range("A1"), order1:=xlAscending, _
key2:=Me.Range("B1"), order2:=xlAscending, _
heder:=xlYes
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"abolbashaari" wrote in message
...
can i sort my data automatically without click on "sort" icon



  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 5
Default sorting

What is this code and how does it do and how can i inter my data for sorting
automaticlly

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:C" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

Me.Cells.Sort key1:=Me.Range("A1"), order1:=xlAscending, _
key2:=Me.Range("B1"), order2:=xlAscending, _
heder:=xlYes
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"abolbashaari" wrote in message
...
can i sort my data automatically without click on "sort" icon




  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,420
Default sorting

Do what it says, and change some data column A or B, and see what happens.

--
__________________________________
HTH

Bob

"abolbashari" wrote in message
...
What is this code and how does it do and how can i inter my data for
sorting
automaticlly

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:C" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

Me.Cells.Sort key1:=Me.Range("A1"), order1:=xlAscending, _
key2:=Me.Range("B1"), order2:=xlAscending, _
heder:=xlYes
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"abolbashaari" wrote in message
...
can i sort my data automatically without click on "sort" icon








  #6   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 5
Default sorting

i found error finaly .correct header spell in code.


"Bob Phillips" wrote:

Do what it says, and change some data column A or B, and see what happens.

--
__________________________________
HTH

Bob

"abolbashari" wrote in message
...
What is this code and how does it do and how can i inter my data for
sorting
automaticlly

"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:C" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then

Me.Cells.Sort key1:=Me.Range("A1"), order1:=xlAscending, _
key2:=Me.Range("B1"), order2:=xlAscending, _
heder:=xlYes
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"abolbashaari" wrote in message
...
can i sort my data automatically without click on "sort" icon






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
Sorting VLookup vs Sorting SumProduct Lauren Excel Discussion (Misc queries) 1 August 21st 07 12:19 AM
Sorting TimB via OfficeKB.com Charts and Charting in Excel 1 March 19th 07 04:21 PM
Sorting: Sorting by the First Character dzuy Excel Discussion (Misc queries) 2 June 22nd 06 08:27 PM
Sorting Joe Gieder Excel Worksheet Functions 0 May 4th 06 01:52 PM
Sorting Kmarie Excel Discussion (Misc queries) 2 May 21st 05 04:13 AM


All times are GMT +1. The time now is 09:25 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"