ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort control doesn't sort top line (https://www.excelbanter.com/excel-programming/377540-sort-control-doesnt-sort-top-line.html)

Humphrey Bogart

Sort control doesn't sort top line
 
I have a spreadsheet with several columns, and a control button above each
one to sort the sheet by that column.

For one of the columns, it sometimes (not always) leaves the first row out
of the sort (first row remains on top, rest of the rows get sorted.

The sort buttons occupy rows 1 and 2, the column headings are on row 3, and
the data begins in row 4. Here is the code behind the button:

Private Sub Sort_status_Click()
Range("A4:D200").Sort Key1:=Range("D4"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
End Sub



Ardus Petus

Sort control doesn't sort top line
 
Try :
Header:=xlNo

HTH,--
AP

"Humphrey Bogart" <Humphrey a écrit dans
le message de news:
...
I have a spreadsheet with several columns, and a control button above each
one to sort the sheet by that column.

For one of the columns, it sometimes (not always) leaves the first row out
of the sort (first row remains on top, rest of the rows get sorted.

The sort buttons occupy rows 1 and 2, the column headings are on row 3,
and
the data begins in row 4. Here is the code behind the button:

Private Sub Sort_status_Click()
Range("A4:D200").Sort Key1:=Range("D4"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
End Sub





Humphrey Bogart[_2_]

Sort control doesn't sort top line
 
Thanks - that seems to have done the trick.

Try :
Header:=xlNo


I have a spreadsheet with several columns, and a control button above each
one to sort the sheet by that column.

For one of the columns, it sometimes (not always) leaves the first row out
of the sort (first row remains on top, rest of the rows get sorted.

The sort buttons occupy rows 1 and 2, the column headings are on row 3,
and
the data begins in row 4. Here is the code behind the button:

Private Sub Sort_status_Click()
Range("A4:D200").Sort Key1:=Range("D4"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
End Sub




All times are GMT +1. The time now is 02:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com