Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 102
Default Macro to sort - Issue

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??
--
Thanks

Lise
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default Macro to sort - Issue

Please post your code. HTH Otto
"Lise" wrote in message
...
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??
--
Thanks

Lise



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 102
Default Macro to sort - Issue

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" wrote:

Please post your code. HTH Otto
"Lise" wrote in message
...
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??
--
Thanks

Lise




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Macro to sort - Issue

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

On Thu, 29 Jan 2009 14:25:01 -0800, Lise
wrote:

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


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 102
Default Macro to sort - Issue

Fantastic Gord - thanks so much.
--
Thanks

Lise


"Gord Dibben" wrote:

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

On Thu, 29 Jan 2009 14:25:01 -0800, Lise
wrote:

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



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
Simple sort issue Eloise Excel Discussion (Misc queries) 2 April 2nd 08 10:50 PM
Sort issue Patrick C. Simonds Excel Worksheet Functions 1 December 30th 07 11:37 AM
Excel Macro- sort issue in Excel2003 Radhakrishna k.v.n.r[_2_] Excel Worksheet Functions 1 October 26th 07 10:02 AM
Sort/Filter issue terri Excel Worksheet Functions 4 May 16th 07 04:46 PM
Header Rows and Sort Issue MikeL. Excel Discussion (Misc queries) 1 March 28th 06 12:23 AM


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