Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sort not working | Excel Worksheet Functions | |||
SORT not working | Excel Programming | |||
Data Sort NOT working... | Excel Discussion (Misc queries) | |||
Sort not working | Excel Programming | |||
Sort Left to Right not working | Excel Discussion (Misc queries) |