PC Review


Reply
Thread Tools Rate Thread

Autosort but leave header alone

 
 
ssGuru
Guest
Posts: n/a
 
      3rd Aug 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      3rd Aug 2007
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
>
>

 
Reply With Quote
 
ssGuru
Guest
Posts: n/a
 
      3rd Aug 2007
On Aug 3, 12:12 pm, Tom Ogilvy <TomOgi...@discussions.microsoft.com>
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

 
Reply With Quote
 
=?Utf-8?B?cDQ1Y2Fs?=
Guest
Posts: n/a
 
      3rd Aug 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: if header row leave a statement Susan Microsoft Excel Programming 0 11th Mar 2009 01:12 PM
autosort Anthony Microsoft Excel Programming 1 13th Jul 2008 08:45 AM
delete message body lin local cache but leave header in Outlook? Joss Microsoft Outlook Discussion 0 3rd Jul 2006 08:59 AM
delete message body lin local cache but leave header in Outlook? Joss Microsoft Outlook Discussion 0 3rd Jul 2006 08:59 AM
How do I leave the header out of the message window for incoming . =?Utf-8?B?SGVucnlI?= Microsoft Outlook Discussion 1 15th Nov 2004 05:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:54 PM.