Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Sort code not working in 07

Hi Pyrite,

I do a very similar thing in one of my workbooks. When the user clicks
on a header title I call the routine below from within the
SelectionChange event. It works fine in both 03 and 07 versions of
Excel.

Beware wrap-around...


Public Sub DoSort(ByRef rngData As Range, ByRef rngKey As Range,
Optional ByVal Hdr As Long, Optional ByVal Ordr As Long)
' Hdr...
' 0 = xlGuess
' 1 = xlYes
' 2 = xlNo

On Error Resume Next

If Ordr = 0 Then Ordr = 1 'xlAscending by default

rngData.Sort Key1:=rngKey, Order1:=Ordr, Header:=Hdr,
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortTextAsNumbers

End Sub


Assuming that your CommandButton lives in the Worksheet module, you
would call this routine from your CommandButton#_Click routines like
so...

Call DoSort(Me.Range("C9:G407"), Me.Range("C9"))

HTH, Nick H
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
sort not working stevemalee[_2_] Excel Worksheet Functions 3 March 9th 09 11:49 PM
SORT not working WLMPilot Excel Programming 1 January 22nd 07 01:14 PM
Data Sort NOT working... Bob Barnes Excel Discussion (Misc queries) 1 June 20th 06 11:00 PM
Sort not working STEVEB Excel Programming 0 February 7th 06 06:12 PM
Sort Left to Right not working Juan Excel Discussion (Misc queries) 3 July 29th 05 07:26 PM


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"