+ Reply to Thread
Results 1 to 4 of 4

How to sort on two condition with VBA?

  1. #1
    Forum Contributor
    Join Date
    11-01-2016
    Location
    Prague
    MS-Off Ver
    2013
    Posts
    121

    How to sort on two condition with VBA?

    Hello Everyone,

    I have a table as below. I am not good at VBA, so I searched and applied some sorting tricks but its not giving me the exact result I am looking for.

    Basically, I have a Column D where its checking the cases >> If(and(B2=0,C2<>0) and putting TRUE - FALSE accordingly. My goal is, having employees who has FALSE row on top but with all related employee rows.

    Any advice how can do this ?

    Capture.PNG

    Thanks a lot
    Orhan
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: How to sort on two condition with VBA?

    Try

    Please Login or Register  to view this content.
    Kind regards
    Leo

  3. #3
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: How to sort on two condition with VBA?

    LeoTaxi,

    I'm sorry if I'm following this thread. I test your code and it works nicely.
    Thank you LeoTaxi as I learn something new from you.

    But I don't know why I need to change the formula in column D
    without apostrophe for the false and true ---> =IF(AND(B6=0,C6<>0),FALSE,TRUE)

    I wonder why if the formula ---> =IF(AND(B6=0,C6<>0),"FALSE","TRUE")
    then the calculation formula in column E doesn't work ?

    Thank you once again.
    Last edited by jeffreybrown; 11-16-2018 at 08:10 AM. Reason: Removed full quote!

  4. #4
    Forum Contributor
    Join Date
    11-01-2016
    Location
    Prague
    MS-Off Ver
    2013
    Posts
    121

    Re: How to sort on two condition with VBA?

    Thank you very much LeoTaxi. This is the exact code I am looking for.

    @karmapala, you are right. It didnt work in first try. As far as I can understand, formula in E column is looking for exact "FALSE" value in order to do the countif. But column D value is actually >> "=IF(AND(B6=0,C6<>0),"FALSE","TRUE")" although the result is "FALSE" itself. So, just before the countif code, added an additional code which makes copy paste with values for column D, it worked perfectly.

    That was my work around. Hope it helps.

    Thanks

+ 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. Named range to sort with condition
    By jaryszek in forum Excel Formulas & Functions
    Replies: 23
    Last Post: 04-04-2018, 10:13 AM
  2. Dynamic sort based on a condition & its Ranking.
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2017, 08:48 PM
  3. Dynamic sort based on a condition & its Ranking.
    By acsishere in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2017, 03:08 PM
  4. Sort all names based on condition
    By xatomicx in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-17-2017, 01:44 AM
  5. Sort index match if condition
    By Ravenousdead in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-09-2014, 12:24 PM
  6. Making a condition in the Sort function
    By hbksean in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-07-2012, 09:52 PM
  7. Sort spreadsheets that meet a certain condition
    By samnic in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2010, 07:14 AM

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