Macro to sort - Issue

L

Lise

Hi

I have set-up a macro to sort the worksheet as a whole alphabetically on
Column 1 when CTL - p is entered which most time works well - however I have
one sheet where it continually includes he header row in the search instead
of leaving it at the top as it does for the other work sheets - what am I
doing wrong please??
 
L

Lise

Hi Otto

I hope thi sis what you're after :)

Sub Sort()
'
' Sort Macro
' Macro recorded 29/01/2009 by seniorl
'
' Keyboard Shortcut: Ctrl+p
'
Cells.Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=2, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveWorkbook.Save
End Sub
--
Thanks

Lise


Otto Moehrbach said:
Please post your code. HTH Otto
 
G

Gord Dibben

Excel usually "guesses" correctly if the header row is formatted differently
or has a different data type than the rows below.

You can change Header:=xlGuess to Header:=xlYes

or just bold A1............safer changing the code, then you take it out of
Excel's hands.

BTW................Cells.Select selects all cells on the sheet which slows
things down

Maybe ActiveSheet.UsedRange.Select


Gord Dibben MS Excel MVP
 
Top