+ Reply to Thread
Results 1 to 22 of 22

Value based on dropdown selection (multiple entries separated by comma)

  1. #1
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Value based on dropdown selection (multiple entries separated by comma)

    Hello,

    I have two sheets in my excel named: "Risk Level" and "Jurisdiction Risk Register".

    In sheet "Risk Level", cell E2, I have the option to select countries (the list of countries comes from "Jurisdiction Risk Register" sheet). There is a VBA code, which allows me to select multiple countries separated by comma.

    My goal is to have a specific value in cell F2 (highlighted in blue) based on dropdown selection in cell E2. The logic is as follows:

    Rule 1. If E2 contains any country that is classified "CRITICAL", then the value of F2 should be equal to "PROHIBITED"
    Rule 2. IF E2 contains any country that is classified "VERY HIGH", then the value of F2 should be equal to "HIGH"
    Rule 3. IF E2 contains any country that is classified "HIGH", then the value of F2 should be equal to "HIGH"
    Rule 4. IF E2 contains any country that is classified "MEDIUM", then the value of F2 should be equal to "MEDIUM"
    Rule 5. IF E2 contains country(ies) that are all classified "LOW", then the value of F2 should be equal to "LOW"

    The country risk classification is based on column D in sheet named "Jurisdiction Risk Register"

    The above five rules are in order of their priority meaning that Rule 1 overrides Rule 2 which overrides Rule 3 and so on. For example, if cell E2 is equal to "Russia, Armenia" then the value of F2 should be "CRITICAL" (Here Russia is classified as "CRITICAL" /Rule 1/, while Armenia is classified as "MEDIUM" /Rule 4/)

    I know this might sound a little bit complicated but any help is much appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2505 and WPS V2024(12.1.0.18543)
    Posts
    4,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    This code obtains the highest severity result based on E2 query

    Please Login or Register  to view this content.

    This code separates the results obtained from E2 query with commas

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by wk9128; 08-05-2024 at 07:21 AM.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Value based on dropdown selection (multiple entries separated by comma)

    It seems when I select "Afghanistan, Bulgaria" it returns a value of "not found" in F2. However, it should have returned "PROHIBITED", as Afghanistan is "Critical" and Bulgaria is "Very High" (Rule 1 and 2, and Rule 1 should override Rule 2 )

  5. #5
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Hello,

    Thanks for your help. When I put this macros into vba this does not work (maybe I am doing something wrong). Could you please put this into the excel, so that I can download and test it? Thank you very much.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Updated file with formula.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    OK, I understand now. Formula developed on iPad, so no capabilty for VBA and, hence, multi-select.

    I will review and get back to you.

  8. #8
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2505 and WPS V2024(12.1.0.18543)
    Posts
    4,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Hi @emilemil222 Response to POST # 5, the attachment has been prepared and placed in POST # 2

  9. #9
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Thanks for the response, could you please state what is the difference between Run1 and Run 2 buttons

  10. #10
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2505 and WPS V2024(12.1.0.18543)
    Posts
    4,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Because I should say these two, I wonder if you are suitable for either one in order to achieve your goal
    Guess it's the first one

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    OK, here's the formula solution for F2:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    You could even adapt the Worksheet Change Event handler:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Hello,

    Thank you very much this works perfectly. Is it possible to make one small adjustment? With all the rules still in force, whenever, country "Bulgaria" is in selection then the risk level is "High". If Bulgaria is not in the selection then still same logic applies as in my previous post. Thank you very much.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    So, if you have Russia (Critical), and Bulgaria (Very High), you want the outcome to be High, not Prohibited? But Russia and anywhere else would be Prohibited? Bulgaria over-rides all?

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    If my guess was/is correct, the formula would/could look like this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If this does what you want, I can adjust the Worksheet Change Event handler to match.

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    In fact, here's the WSCE handler:

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Sorry for the confusion. Indeed, you noted it correctly. When Russia (Critical) and Bulgaria (Very High) are in selection, the overall risk still should be prohibited. I have mad some changes to the rules (in bold). Can we please formulate formula with the rules below?

    Rule 1. If E2 contains any country that is classified "CRITICAL", then the value of F2 should be equal to "PROHIBITED".

    Rule 2. IF E2 contains "Bulgaria", then the value of F2 should be equal to "HIGH".

    Rule 3. IF E2 contains any country that is classified "VERY HIGH", then the value of F2 should be equal to "PROHIBITED".

    Rule 4. IF E2 contains any country that is classified "HIGH", then the value of F2 should be equal to "HIGH"

    Rule 5. IF E2 contains any country that is classified "MEDIUM", then the value of F2 should be equal to "MEDIUM"

    Rule 6. IF E2 contains country(ies) that are all classified "LOW", then the value of F2 should be equal to "LOW"

  18. #18
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2505 and WPS V2024(12.1.0.18543)
    Posts
    4,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    ANS.POST#17

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by wk9128; 08-07-2024 at 07:58 PM.

  19. #19
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Value based on dropdown selection (multiple entries separated by comma)

    hi thanks for the response. This does not seem to work. Could you please upload the vba code into the excel (post #1), so that I can download and test it? Also, does it have rule 2 (on Bulgaria) incorporated?. Thank you.

  20. #20
    Registered User
    Join Date
    05-09-2020
    Location
    Yerevan
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Value based on dropdown selection (multiple entries separated by comma)

    based on this formula when I select Russia (Critical), and Bulgaria (Very High) it returns "HIGH", however it should return "Prohibited" (see post #17)

  21. #21
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    I have made several attempts to create a formula that copes with the presence of Bulgaria. I can handle Bulgaria (Very High) and, say, Russia (Critical) returning Prohibited. However, I can't handle Bulgaria (Very High) and, say, Cameroon (Very High) returning Prohibited. Bulgaria always forces a return of High.

    Here's the last couple of variations on a theme:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The problem I'm struggling with, is that E2 will contain Bulgaria plus some other countries, and the variable risk will contain Very High.
    Last edited by TMS; 08-07-2024 at 08:01 PM.

  22. #22
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2505 and WPS V2024(12.1.0.18543)
    Posts
    4,113

    Re: Value based on dropdown selection (multiple entries separated by comma)

    Hi @emilemil222 Response to POST # 20, the attachment has been prepared and placed in POST # 18

+ 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: 0
    Last Post: 05-10-2022, 05:01 PM
  2. Replies: 6
    Last Post: 09-15-2021, 05:20 AM
  3. Split comma separated entries to new rows
    By dandi10 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-02-2020, 07:59 PM
  4. Multiple Dropdown selection & Column Groupings based on dropdown selection
    By rabrol in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2018, 10:23 AM
  5. [SOLVED] Split comma separated entries to new row
    By trefix in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-26-2014, 04:56 AM
  6. [SOLVED] VBA: To Split comma separated entries to new rows
    By Cytokine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-19-2014, 08:58 PM
  7. Replies: 3
    Last Post: 03-30-2013, 08:36 AM

Tags for this Thread

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