+ Reply to Thread
Results 1 to 12 of 12

Automatically give status to condition

  1. #1
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Automatically give status to condition

    Say that I have 3 variables (condition1, condition2 and condition3) conditions...thus, 3 Factorial + 2 would get a total of 8 combinations.

    For easy understanding, say that each condition value can either be 'Yes' or 'No' (or you can think of it as either 0 or non zero).

    Condition 1 Condition 2 Condition 3 Desired Result
    Yes No No Condition 1 ONLY
    Yes Yes No Condition 1 & Condition 2
    Yes No Yes Condition 1 & Condition 3
    No Yes No Condition 2 ONLY
    No Yes Yes Condition 2 & Condition 3
    No No Yes Condition 3 ONLY
    No No No No Condition
    Yes Yes Yes All Condition

    My question is, how do I do in VBA to get which condition to get that result?

    For this example, it is only 3 conditions, but the actual, it can be 4 to 6 conditions and thus it is not feasible to think of the many combinations it can get and to write an IF statement for each conditions.

    Thus, is there an easier way?


    NOTE: Macro works as I wanted. However, if I were to add more 'Sheets', that means that there's more conditions. It is very easy and quick to add more variables. But the difficult part is the IF statement where I need to capture all conditions. Thus, instead of me writing down what each message box will write based on each scenario, I need VBA to know and tell me instead.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by dluhut; 09-21-2018 at 04:43 PM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,166

    Re: Automatically give status to condition

    How about
    Please Login or Register  to view this content.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Automatically give status to condition

    a formula like

    =100*($A1="yes")+10*($B1="yes")+($C1="yes")

    will return
    000
    001
    010
    011
    'etc

    depending on which column(s) is Yes.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Automatically give status to condition

    Hi Fluff13,

    Thanks for your reply.

    The conditions that I had is actually a variable. Nothing is listed in the cell/range in Excel Workbook.

    so in short, those conditions that I had are literally

    Please Login or Register  to view this content.
    The IF condition (marked in red) is where I'd like to have the code where given the each conditions that can happen, give me the result value. And that result value is on the 1st post above
    Last edited by dluhut; 09-21-2018 at 04:15 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Automatically give status to condition

    Hi mikerickson,

    The table shown above is not values that's in the excel cells...but rather, to show for each condition value, what the desired result should show via VBA output...and those conditions are variables.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,166

    Re: Automatically give status to condition

    In that case can you please supply a workbook, showing what you have & what you want?

  7. #7
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Automatically give status to condition

    Any VBA experts that could help me out?

  8. #8
    Forum Contributor
    Join Date
    01-03-2018
    Location
    Fukuoka, Japan
    MS-Off Ver
    Excel 2013
    Posts
    123

    Re: Automatically give status to condition

    How about this one?

    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,674

    Re: Automatically give status to condition

    Assuming Header in A1:C1.
    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Automatically give status to condition

    Hi Jindon,

    Do I just copy and paste your code? Do I need any part of my existing code to go with yours?

    Because when I use yours, I have a run-time error 1004, and when I debug, below is the portion where it got highlighted.

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Automatically give status to condition

    @yujin,

    Solved. Thank you and reps up to you

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,674

    Re: Automatically give status to condition

    See...................

+ 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. Give status as unique for the names
    By Noman050 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-31-2018, 01:24 PM
  2. IF Condition statement for Final Status
    By Rushendra in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-02-2016, 04:50 AM
  3. [SOLVED] Check read-only status, and if locked - skip all code and give a message box
    By jedemeyer1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-08-2014, 01:32 AM
  4. Replies: 3
    Last Post: 09-11-2014, 04:32 PM
  5. [SOLVED] How to Set a Condition that colors a cell based on status
    By Dmarz in forum Excel General
    Replies: 4
    Last Post: 12-03-2012, 09:56 AM
  6. Replies: 4
    Last Post: 04-08-2012, 09:43 PM
  7. [SOLVED] i want to give more than 6 condition by using if statement
    By Sushil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2005, 11:06 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