+ Reply to Thread
Results 1 to 2 of 2

Sort by evaluated value and then by actual value

  1. #1
    Registered User
    Join Date
    01-30-2015
    Location
    D/FW, Texas
    MS-Off Ver
    2013
    Posts
    18

    Sort by evaluated value and then by actual value

    I have an table with part numbers and quantity numbers.

    The quantity numbers may be positive, indicating the quantity in stock, or the quantity may be negative, indicating the amount needed to be ordered, or the quantity number may be zero, indicating both none in stock and none needed.

    I need to sort the table by part numbers of those with positive quantity numbers and then sort the part numbers of those with negative part numbers.

    Unsorted:

    Part# Quantity
    1 -50
    5 80
    9 -7
    3 10
    7 -100
    2 200

    Desired Sort:

    Part# Quantity
    2 200
    3 10
    5 80
    1 -50
    7 -100
    9 -7

    All the Part#s that have a positive quantity are in order by part number and then all the Part#s that have a negative quantity are in order by part number.

    And I wish to perform this through VBA.

    I think one solution might involve performing some sort of conditional formatting to use as a sort key but I do not want something that will be visible to the users.

    By the same token, I think another solution might involve an additional column that contains a formula to evaluate whether the quantity is positive or negative but, again, the column should not be visible or accessible to the user.

    Any ideas?

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,370

    Re: Sort by evaluated value and then by actual value

    Do a three part sort - assumes that your data is in A:B and headers are in row 1. This does not include error checking in case there are all positive or all negative values, and it treats 0 as negative (you never say)

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

+ 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. Replies: 2
    Last Post: 06-02-2014, 09:34 AM
  2. Replies: 9
    Last Post: 06-14-2013, 04:38 AM
  3. function not being evaluated
    By fenixasin in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-21-2012, 02:43 PM
  4. How to sort date by actual date and not first number!!
    By Brice112 in forum Excel General
    Replies: 2
    Last Post: 05-04-2010, 06:19 PM
  5. Cell Being Evaluated Contains a Constant
    By Rcketfan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-27-2007, 02:41 PM
  6. [SOLVED] the cell currently being evaluated contains a constant
    By Barrie Wells in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 12:05 AM
  7. [SOLVED] the cell currently being evaluated contains a constant
    By Barrie Wells in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2005, 10:05 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