Unexpected behavior in Excel when sorting

  • Thread starter Thread starter DaveC426913
  • Start date Start date
  • Tags Tags
    Excel Sorting
AI Thread Summary
Sorting issues in Excel often arise when the first row is inadvertently treated as a header, causing it to remain unsorted during operations. In this discussion, a user describes their struggle with sorting a sheet based on Column D, noting that the first row consistently becomes deselected during the sorting process. Despite attempts to sort other columns, the issue persists. The user finds a workaround by cutting and pasting the first row, which resolves the sorting problem. Further insights reveal that Excel requires users to explicitly define header rows by freezing them, which prevents the software from treating them as regular data rows. The conversation highlights the complexities of Excel's sorting functions and the importance of understanding how the software interprets data structure. Additionally, the user reflects on the troubleshooting process, emphasizing that articulating the problem can lead to discovering solutions. The discussion underscores the need for users to familiarize themselves with Excel's features to avoid common pitfalls in data management.
DaveC426913
Gold Member
Messages
23,834
Reaction score
7,830
TL;DR Summary
When I try to sort a spreadsheet, it ignores the first row (not a header.)
I'm trying to sort this sheet in Excel. I want to sort it on Column D.

1698778735967.png


I select the entire page by clicking the black arrow in the upper left corner:

1698778755418.png


Now I Data > Sort which brings up a dialogue where I specify the column I want to sort by :

1698778780227.png


(I can already tell there may be a problem - the first row has become deselected. This was not my doing. It happens every time):

1698778792033.png


An indeed, the sheet is sorted on column D, except the first row:

1698778811534.png


It doesn't matter how many times I do this - it's not a slip of the thumb - it always happens on this sheet. (And I have encountered this before, so it's not an artefact of this sheet only).

It's not a matter of data type of something life that. It happens on any other column I try to sort on:This is sorting on column A:

1698778859779.png


This is sorting on column F:

1698778872229.png


The only thing that worked was to cut and paste the row from the top to the bottom:

1698778913531.png


And now it sorts OK:

1698778939998.png
What am I doing wrong?
 
Computer science news on Phys.org
[ UPDATE ]
Man there is nothing so effective for trouble-shooting as writing up the problem unambiguously in preparation for asking for help... :sorry:

When I went to update the veeery last screenshot, I saw this:
1698779437151.png
 
  • Like
  • Haha
Likes jrmichler, berkeman, jedishrfu and 4 others
Is that why your first post has all strikeout text?
 
jedishrfu said:
Is that why your first post has all strikeout text?
Yes. Save readers the time of reading through it all, only to discover I'd found the answer.

And I figured, since I'd already made the entire post, deleting it would only deprive some future readers in the same boat from reaping the benefit of my trials and tribulations.
 
  • Like
Likes jedishrfu, Baluncore and berkeman
DaveC426913 said:
Man there is nothing so effective for trouble-shooting as writing up the problem unambiguously in preparation for asking for help...
Also for solving engineering problems....
 
Probably the most important advantage of a forum like PF, is that the OP needs to work out what question to ask. After reading threads like this, we all become humbler.

“The only interesting answers are those which destroy the question”. —Susan Sontag
 
  • Like
Likes DaveC426913
Dave, I also had to track this down one time. Obvious once you know about the option but MS Office software has SO many options that it's hard to keep track of them all.
 
phinds said:
Dave, I also had to track this down one time. Obvious once you know about the option but MS Office software has SO many options that it's hard to keep track of them all.
Indeed. The gotcha in this case was that it the first row's behavior hinted at being a header, but the only way to define a row to behave as a header is to "freeze" it. Which of course, I did not do.

Knowing that's how Excel "handles" headers, one would not think to go looking for an option on a dialogue that said, effectively "Don't become a header, just pretend to act like one - for the moment - and then go back to being a regular row, like nothing ever happened." :mad:
 
  • Informative
  • Like
Likes phinds and Bystander
DaveC426913 said:
[ UPDATE ]
Man there is nothing so effective for trouble-shooting as writing up the problem unambiguously in preparation for asking for help... :sorry:

When I went to update the veeery last screenshot, I saw this:View attachment 334595
I wrote this in my form code:
'TARGET WITHIN RANGE - RUN JOB
ActiveCell.Select
Selection.Sort Key1:=ActiveCell, Order1:=xlAscending, _
HEADER:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
GoTo FINISHED
 
  • #10
Gifovaco said:
I wrote this in my form code:
'TARGET WITHIN RANGE - RUN JOB
ActiveCell.Select
Selection.Sort Key1:=ActiveCell, Order1:=xlAscending, _
HEADER:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
GoTo FINISHED
Excel loves to think for you. In order to totally control it I run a script recursively that deletes ALL formatting. THEN I wrie what I want.... Excel is a 'trick' monster
 

Similar threads

Replies
1
Views
1K
Replies
3
Views
2K
Replies
5
Views
2K
Replies
14
Views
5K
Replies
7
Views
2K
Replies
6
Views
2K
Replies
3
Views
4K
Back
Top