+ Reply to Thread
Results 1 to 8 of 8

Data sort, moving "empty" formula cells to bottom

  1. #1
    Registered User
    Join Date
    12-17-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    6

    Data sort, moving "empty" formula cells to bottom

    Hope all is well. I've been frustrated trying to figure this out and was hoping someone could assist me. My basic issue is that I need to do a descending sort for a table but I keep getting blank rows above the data. I've attached the sheet so you can reference it.

    Cells B5:16 contain drop downs linking to the sheet "Data." Basically you select the items you want in the drop down from in B5:B16, then click the "SORT DATA" button. The data is filled using the index/match combination. A user may only use for example 9 out of 12 rows. The issue is when I sort the data descending by column M I get in this case 3 empty rows on top because there are index/match formulas in the "empty" cells.

    How do I edit my code so that if a cell appears to be empty in column M for example that entire row gets sorted to the bottom of the list.

    Any help would be much appreciated! I've been googling and reading for days and I can't get it to work right.
    Attached Files Attached Files
    Last edited by skfinance; 12-28-2010 at 12:09 PM.

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Data sort, moving "empty" formula cells to bottom

    Try this code:

    Please Login or Register  to view this content.

    The idea is to do 2 sorts: the first sorts on column B (in case a row was skipped) to bring the fund names together starting in first row. Then the second sort only sorts on the used rows (based on the number of funds selected in column B - the "n" value used in the code).
    Last edited by Cutter; 12-17-2010 at 02:37 PM.

  3. #3
    Registered User
    Join Date
    12-17-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Data sort, moving "empty" formula cells to bottom

    Sorry for the late response I had gone out of town over the weekend. That works perfectly! How would you suggest I edit the code to incorporate three tables on the same sheet to be sorted in a similar fashion but independent that each other?

    When I tried to edit it to include the other tables I get a "Compile Error: Duplicate Declaration in Current Scope." I'm assuming this is to the same variable being used twice?

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Data sort, moving "empty" formula cells to bottom

    Post your code.

  5. #5
    Registered User
    Join Date
    12-17-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Data sort, moving "empty" formula cells to bottom

    So as of now I'm running it like this and it works perfectly but there has to be a more efficient way. I'm basically linking the sorts to each other to run them on the 4 sections...

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Data sort, moving "empty" formula cells to bottom

    I'm not sure how much "more efficient" this code is but you can decide for yourself if you want to use it. I have run it and it works as expected. In any event you must turn ScreenUpdating back on before ending your macro. Your code turns it off but ends without turning it back on.

    Here is code to loop through the ranges:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-17-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Data sort, moving "empty" formula cells to bottom

    Thank you very much! Perfect!

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Data sort, moving "empty" formula cells to bottom

    You're welcome, glad to help.
    Don't forget to mark your thread as SOLVED.

+ 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