Unexpected behavior in Excel when sorting

In summary, Excel may display unexpected behavior when sorting data, such as rearranging rows or columns in a way that is not intended. This can be caused by hidden characters or formatting in the cells, or by not selecting all the data to be sorted. To avoid this, it is important to carefully review the data and make sure all cells are formatted correctly before sorting. Additionally, using the "Sort Warning" option can help identify any potential issues before the sorting is applied.
  • #1
DaveC426913
Gold Member
22,986
6,659
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
  • #2
[ 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
  • #3
Is that why your first post has all strikeout text?
 
  • #4
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
  • #5
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....
 
  • #6
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
  • #7
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.
 
  • #8
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
  • #9
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
3K
Replies
7
Views
2K
Replies
6
Views
1K
Replies
3
Views
3K
Back
Top