A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

sorting



 
 
Thread Tools Display Modes
  #1  
Old August 19th, 2008, 05:38 AM posted to microsoft.public.excel.newusers
abolbashaari
external usenet poster
 
Posts: 1
Default sorting

can i sort my data automatically without click on "sort" icon
  #2  
Old August 19th, 2008, 10:17 AM posted to microsoft.public.excel.newusers
Gary''s Student
external usenet poster
 
Posts: 7,584
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  
Old August 19th, 2008, 11:21 AM posted to microsoft.public.excel.newusers
Bob Phillips[_2_]
external usenet poster
 
Posts: 1,562
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  
Old August 20th, 2008, 09:53 AM posted to microsoft.public.excel.newusers
abolbashari
external usenet poster
 
Posts: 6
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  
Old August 20th, 2008, 01:13 PM posted to microsoft.public.excel.newusers
Bob Phillips[_2_]
external usenet poster
 
Posts: 1,562
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  
Old August 20th, 2008, 09:09 PM posted to microsoft.public.excel.newusers
abolbashari
external usenet poster
 
Posts: 6
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






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:26 AM.


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