+ Reply to Thread
Results 1 to 5 of 5

Sort order with Blanks

  1. #1
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Sort order with Blanks

    I am sorting a worksheet and finding that I am getting confusing (to me) results with respect to the treatment of blanks. In one workbook, an ascending order sort puts rows with blanks first and in another workbook, it puts them last. ( Both in an ascending sort) .

    I have checked for leading blank characters that might be confusing things in the non-blank cells and find none. (Used Left( A1, 1) to have Excel tell me what the first character is. It is the character I see visibly. Eg if A1 contains "Dog" it returns "D".)

    I have used IF (A1="",true ,false) to verify that the visibly blank cells are indeed blank.

    I am doing the sort in a macro (recorded by excel), but get the same result when I do the sort directgly through the user interface.

    The help text says that blanks always sort to the end, I am seeing blanks at the end when I sort descending but as stated above, in one case it is putting the blank rows first.

    (The exact data in the two workbooks is not the same.)

    Can anyone suggest what might be causing the blanks to sort first?

    If requested I can supply the worksheet with sample data.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Sort order with Blanks

    =A1="" doesn't tell you that a cell is empty.

    Try =ISBLANK("A1")
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Sort order with Blanks

    Hi DanBlum

    A workbook would be good
    I can supply the worksheet with sample data
    Include your code in the workbook
    I am doing the sort in a macro (recorded by excel),
    If you have more than one workbook, post them both WITH Code
    The exact data in the two workbooks is not the same
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Registered User
    Join Date
    02-18-2009
    Location
    Apex, NC, USA
    MS-Off Ver
    Office 365
    Posts
    64

    Re: Sort order with Blanks

    Thank you. I did the =isblank(a1) and sure enough it came out FALSE. (to my surprise)

    So, please continue to help me. The column of cells I am testing (or sorting) have their value set by the following sequence:

    First they have an if test as follows: =if( condition, "", "unique test string"). This sets some of the cell to whatever "" is....which I thought was blank, but I apparently don't understand.

    Then, via a macro, that column gets copied to the clipboard and paste values to a new column. It is this new column of cells from the paste values that I am having sort trouble with.

    Under the true condition, I need to set the value to something the user sees as blank and which sorts at the end of other alphanumeric strings.
    Last edited by DanBlum; 07-22-2011 at 11:13 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Sort order with Blanks

    "" is a zero-length (null) string. Like any string in Excel, it is larger than any number.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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