+ Reply to Thread
Results 1 to 5 of 5

Sorting Output with Formulas in It

  1. #1
    Valued Forum Contributor
    Join Date
    07-16-2007
    Location
    GA
    MS-Off Ver
    Office 365 - Version 2403
    Posts
    1,054

    Sorting Output with Formulas in It

    Hi Excel Users,

    I have a formula that looks like the following & works as it should:

    =IF(G16="TC","TC",IF(G16="--","PEN",IF(F16<=0,"",IF(F16<=TODAY()+5,"A",IF(F16>TODAY()+16,"C",IF(F16>=TODAY()+6,"B",IF(F16<=TODAY()+15,"B")))))))

    However, I would like to sort the output - A,B,C, etc. in ascending or descending order.

    However, the way my formula appears to be set up, instead of sorting the desired output, it's sorting the 'i' in the IF formula instead.

    How can sort the calculate output, without changing the formula, when I select the Ascending or Descenting options? If necessary, I can or will change my formula, but at the moment, for it's main other purpose, it works well.

    Thanks
    Last edited by VBA Noob; 01-04-2009 at 03:15 PM.
    MyCon
    -- Using Latest Version of Excel

  2. #2
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64
    You need to highlight *all* your data and sort it based on the formula column! For instance, if your formulas are in Column E and the rest of the data is in Cols F and G, you highlight E, F, & G and sort based on E. Obviously, if you also have related data in Columns A:D or beyond Column G, you will need to include that too or you will have a small disaster on your hands.
    Last edited by clownfish; 01-03-2009 at 02:58 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    07-16-2007
    Location
    GA
    MS-Off Ver
    Office 365 - Version 2403
    Posts
    1,054

    Question Sorting Columns with Formulas In It

    Hi Clownfish,

    Thanks for replying. However, I'm not quite understanding on you take *all* & sort the desired columns with formulas in it.

    Another thing that I didn't state before. In the column, which has the formula in it, sometimes produces no results, as it should be because there's no data to sort in a particular row. Therefore, the column has A,B,C results & "blank" or "empty" results.

    When attempting to sor the column, the 'blank' or 'empty rows are being moved to the top, even though it's suppose to follow the A,B,C ascending order.

    How do I get this columm to sort properly?

    Thanks again


    Quote Originally Posted by clownfish View Post
    You need to highlight *all* your data and sort it based on the formula column! For instance, if your formulas are in Column E and the rest of the data is in Cols F and G, you highlight E, F, & G and sort based on E. Obviously, if you also have related data in Columns A:D or beyond Column G, you will need to include that too or you will have a small disaster on your hands.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Post a workbook that illustrates what you're trying to do?
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    12-30-2008
    Location
    Vermont, USA
    MS-Off Ver
    Excel 2003
    Posts
    64
    I'm assuming your first problem is fixed now-- the column with formulas is now sorting (at least in some fashion) based on the "ouput" of the formulas rather than on "=IF(..." or whatever?

    About the other problem, I think Excel sees this: "" as the "highest" text value and it will therefore outrank any other text, which would explain why your blanks are appearing at the top of your sorted list when you sort ascending.

    There's no great way to get around this, but here are a couple of different hacks:

    replace the "" in your IF statement with CHAR(158), as in =IF(A2>55,B2+C2,CHAR(158))
    instead of
    =IF(A2>55,B2+C2,"")
    Character 158 appears to be something like a Czech "z", and will always be sorted to the bottom of the list. If it's annoying to you to have anything appearing in the cells that should be blank, you can do this:

    replace the "" in your IF statement with "zzz" and use conditional formatting to make cells in this column that are equal to zzz have the same background and text color (white/white, for instance), which will effectively make them invisible (although they still will look a little odd, because the default cell color in Excel is not actually white, but transparent).

    Somebody else probably has a prettier solution than this!

+ 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