Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Autosort but leave header alone

I have code that nicely sorts any values placed in col 13 and 16 of
some lookup lists.
What code change will cause the sort to ignore a header row?

Private Sub Worksheet_Change(ByVal Target As Range)
'DD Define columns to autosort when record added or deleted
If Target.Column = 13 Or Target.Column = 16 Then
Columns(Target.Column).Sort _
Key1:=Cells(1, Target.Column), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub

Thanks, Dennis

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Autosort but leave header alone

Header:=xlGuess - Excel tries to figure it out
Header:=xlNo - says there is no header, so sort all rows
Header:=xlYes - says there is a header so don't sort that

--
Regards,
Tom Ogilvy

"ssGuru" wrote:

I have code that nicely sorts any values placed in col 13 and 16 of
some lookup lists.
What code change will cause the sort to ignore a header row?

Private Sub Worksheet_Change(ByVal Target As Range)
'DD Define columns to autosort when record added or deleted
If Target.Column = 13 Or Target.Column = 16 Then
Columns(Target.Column).Sort _
Key1:=Cells(1, Target.Column), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub

Thanks, Dennis


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Autosort but leave header alone

On Aug 3, 12:12 pm, Tom Ogilvy
wrote:
Header:=xlGuess - Excel tries to figure it out
Header:=xlNo - says there is no header, so sort all rows
Header:=xlYes - says there is a header so don't sort that

--
Regards,
Tom Ogilvy



"ssGuru" wrote:
I have code that nicely sorts any values placed in col 13 and 16 of
some lookup lists.
What code change will cause the sort to ignore a header row?


Private Sub Worksheet_Change(ByVal Target As Range)
'DD Define columns to autosort when record added or deleted
If Target.Column = 13 Or Target.Column = 16 Then
Columns(Target.Column).Sort _
Key1:=Cells(1, Target.Column), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub


Thanks, Dennis- Hide quoted text -


- Show quoted text -


Thanks Tom. Exactly what I needed.
Dennis

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Autosort but leave header alone

Try replacing
Header:=xlGuess
with either:
Header:=xlNo
or:
Header:=xlYes
(I'm not sure what you mean by 'ignore a header row')

--
p45cal


"ssGuru" wrote:

I have code that nicely sorts any values placed in col 13 and 16 of
some lookup lists.
What code change will cause the sort to ignore a header row?

Private Sub Worksheet_Change(ByVal Target As Range)
'DD Define columns to autosort when record added or deleted
If Target.Column = 13 Or Target.Column = 16 Then
Columns(Target.Column).Sort _
Key1:=Cells(1, Target.Column), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub

Thanks, Dennis


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
Autosort in Excel Riley Snyder Excel Discussion (Misc queries) 2 October 12th 09 02:05 PM
autosort pete Excel Worksheet Functions 1 April 25th 06 11:02 PM
Can I AutoSort without refreshing? JohnPWilks Excel Discussion (Misc queries) 0 March 13th 06 02:48 PM
Can I AutoSort without refreshing? JohnPWilks Excel Discussion (Misc queries) 0 March 13th 06 02:46 PM
AutoSort in VBA tamato43 Excel Discussion (Misc queries) 1 March 30th 05 08:09 AM


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