+ Reply to Thread
Results 1 to 8 of 8

Drop Down List Question

  1. #1
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    54

    Drop Down List Question

    Is it possible to create a list,

    For example:
    Susan
    Jeffrey
    Thomas

    Use the named list to create a drop-down list on a Worksheet (using Data Validation) and when a selection is made from the drop-down list , see different (associated) data, IN THE SAME CELL.

    For example:
    Select "Susan" but get "Sue"
    Select "Jeffrey" but get "Jeff"
    Select "Thomas" but get "Tom"

    I thought about using the Conditional Formatter but that doesn't look like there is an option there for me. Perhaps I need some VBA logic to detect the value in a Cell and then change it (behind the scene).

    What do you think?

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,829

    Re: Drop Down List Question

    If you are using a data validation drop-down, then you are trying to ensure that only valid entries are made, i.e. those within the named range. That means that you cannot have Sue, Jeff or Tom in that cell, as those are invalid entries.

    You would need to use a different cell to display the abbreviated names in, possibly using a formula with VLOOKUP to get the shorter names from a table.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    54

    Re: Drop Down List Question

    Thank you, Pete. Yes, that helps, in that now I know that it's not really possible to do what I was looking for using the Data Validation.

    Sue

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,829

    Re: Drop Down List Question

    Thanks for feeding back, Sue.

    If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post in this thread, and mark the thread as SOLVED.

    Also, you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of any post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Drop Down List Question

    Not Strictly true.

    if you set Data Validation for C2 tp accept a list of names.

    Disable errors in the data validation.

    Then this Macro will do the conversion for you.

    Please Login or Register  to view this content.


    Right Click On Your Sheet Name At the Bottom Of Excel and Select View Code
    Paste this code in the module that opens and close it.
    Attached Files Attached Files
    Last edited by mehmetcik; 03-28-2019 at 06:50 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  6. #6
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    54

    Re: Drop Down List Question

    Thank you, mehmetcik. Your suggestion was just the ticket I needed.

    I, actually, decided to put the function in Workbook_SheetChange( ). This is because the workbook has many sheets, all with the same column holding the same type of data. In my case the value is a "Status". So, rather than update EVERY WorkSheet_Change( ) function, I thought it would be a better idea for me to just add 1 function and modify it to work for me.

    I did run into a problem, however. When selecting a value from the drop-down list, the Workbook_SheetChange( ) function is called. Great. But when the value is changed by selecting a value in the array the function is called again, recursively, from within the function, itself. This caused the logic catching a value not expected. I was able to get around this problem by creating a global variable that would tell the function if it is the first or second time into the function and take action accordingly.

    Thanks, again. This was a fun little problem for me to solve and you helped.

    Here's the code that I used.

    Oh, btw, I have another column that I am doing the same thing with so you will see logic for that, as well. And I change the cell background color, as well, just for cosmetic purposes.

    Oh, last thing ... you will notice that I am doing (mostly) the same thing for two different columns. Normally, I would create a called function to do that work. BUT, I tried and tried and just could not figure out how to pass Target. So, sadly, I gave up. Maybe I'll revisit this when I get a moment.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Drop Down List Question

    Hi

    The way to get over the infinite loop issue is to disable events whilst running the Macro.

    My Optimise Macro disables several Excel Functions, speeding up excel and also preventing a Macro endless loop


    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-01-2016
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    54

    Re: Drop Down List Question

    I'm not sure if my previous reply was sent so ...
    Thanks, again. This additional suggestion looks great. I'll give it a go. Thank you.

+ 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. A Question about a drop down list
    By john dalton in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2014, 06:52 AM
  2. Drop Down list question
    By madhatr in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 01-28-2013, 10:36 AM
  3. Drop Down List Question
    By cody1187 in forum Excel General
    Replies: 7
    Last Post: 02-07-2012, 09:53 AM
  4. Drop Down List Question?
    By DJ-Cavity in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-14-2011, 04:48 PM
  5. Drop-down list question
    By darrellb in forum Excel General
    Replies: 4
    Last Post: 11-20-2010, 05:00 AM
  6. Drop down list question
    By Alex01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-10-2008, 02:34 PM
  7. Drop Down List Question
    By EyeNoNothing in forum Excel General
    Replies: 3
    Last Post: 02-07-2006, 06:25 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