+ Reply to Thread
Results 1 to 4 of 4

Weird Sort Results

Hybrid View

  1. #1
    Registered User
    Join Date
    12-25-2012
    Location
    Los Angeles
    MS-Off Ver
    Officel 2013
    Posts
    82

    Weird Sort Results

    This weird behavior occurs in VBA, or by sorting manually and is repeatable:

    Enter a value in cell A1 and A2
    Select Column A
    Sort Column A (Data/Sort)

    Now clear or enter space in cell A2 so only cell A1 is filled in
    Select Column A
    Sort Column A

    The value in cell A1 is moved to cell A2

    This only happens if cells A1 and A2 have values and are sorted first. If only A1 is filled in and sorted first, the move does not happen

    If you are wondering why I'd want to do a sort when only one cell is filled, I came upon this using VBA where a column may have one or more cells filled in. My workaround was to check to see if there was more then one cell filled before doing the sort. But why is this happening and is there a real fix?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,013

    Re: Weird Sort Results

    I cannot repeat the scenario described (either by clearing cell A2 or by clearing it).
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,918

    Re: Weird Sort Results

    ...clear or enter space...
    A cell with a space is not empty. A space is a character that causes the cursor/printhead to move right without "inking". Try your experiment by hitting the delete key or selecting clear contents...
    Put something in A1 and a space in several rows below, sort...
    Last edited by protonLeah; 01-14-2023 at 06:44 PM.
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    12-25-2012
    Location
    Los Angeles
    MS-Off Ver
    Officel 2013
    Posts
    82

    Re: Weird Sort Results

    Thanks ProtonLeah! You nailed it! My instructions were wrong. Typing spaces in the cell causes the shift. Clearing the cell makes it work as expected.

    I had thought the sort selected cells until it hit a blank cell. I guess it does, but spaces are not "blank"
    Not realizing that had caused several mysterious issues with a project I was working on... That, and UNICODE collating sequence being the opposite of the EPCDIC collating sequence I was accustom to as a life long IBM mainframe programmer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. XIRR - weird results
    By NotanMSFan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-06-2022, 12:33 PM
  2. Weird result when calling sort/filter sub
    By SLWright in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2022, 08:17 AM
  3. Adding rows to table; really weird results
    By Gaellus in forum Excel General
    Replies: 2
    Last Post: 08-24-2021, 10:21 AM
  4. [SOLVED] Weird results from SUMIF
    By lentulax in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-13-2019, 11:21 PM
  5. Weird sort behavior
    By mfactor in forum Excel General
    Replies: 4
    Last Post: 11-21-2009, 01:12 PM
  6. Extracting a delimited CSV gave weird results.
    By Aswathy in forum Excel General
    Replies: 6
    Last Post: 10-21-2008, 04:13 AM
  7. [SOLVED] Weird sorting results
    By J Streger in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2006, 05:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1