+ Reply to Thread
Results 1 to 4 of 4

Macro to sort blank cells to bottom

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    Mesquite, Texas, USA
    MS-Off Ver
    Excel 2010
    Posts
    48

    Macro to sort blank cells to bottom

    I need some help with a macro. I'm trying to sort several columns using a custom sort list. The cells had formulas in them, but I wrote a macro to clear contents is value = " ". That Macro works, but when it sorts the cells, the blanks do not move to the bottom of the column, but remain in their original position. Any ideas?

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Macro to sort blank cells to bottom

    try using value =""
    because you have a space between " " this means there is a character in the cell.

    regards
    Sean

  3. #3
    Registered User
    Join Date
    10-09-2012
    Location
    Mesquite, Texas, USA
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: Macro to sort blank cells to bottom

    Okay, I changed the macro to read Value="" and it still doesn't work. I'm uploading the workbook. Go to the third sheet (labeled 2 for December 2). Notice that line A2:J2 is blank but contains a formula. The shortcut is Ctl+Shift+M. The macro is written to look at any cells that contain a formula but no text and to clear contents so that it is truly a blank cell, then it sorts by a custom list, then will highlight anywhere we are below minimum manpower (cells are defined in the macro). Look at column 2200-0000 on sheet "2". Notice that the first cell is blank but contains a formula refered back to the supervisor Teri. She is off that day, so the macro should move all blanks to the bottom and move everyone up, but it doesn't when I run the macro. However, if I manually select the cells a1:a15 as defined in the macro and manually perfom a custom sort, it works correctly. I'm baffled
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Macro to sort blank cells to bottom

    try changing this line
    .Header = xlGuess

    i tried i, and it sorts them in the correct order and moves them to the top. However a blank still appeared in the list.
    Have to go to work now so maybe have another look later if i get the chance.

    Sean

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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