Autosort but leave header alone

S

ssGuru

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
 
G

Guest

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
 
S

ssGuru

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







- Show quoted text -

Thanks Tom. Exactly what I needed.
Dennis
 
G

Guest

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top