Macro to sort - Issue

  • Thread starter Thread starter Lise
  • Start date Start date
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??
 
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
 
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
 

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

Similar Threads

auto sort macro 1
writing a sort macro 2
Custom Sort order issue 2
Sorting issue with frozen panes 11
Sort Macro: Help with code. 13
How to sort entire spreadsheet by one column sort 5
Sorting 1
Sorting Madness 5

Back
Top