+ Reply to Thread
Results 1 to 8 of 8

Perform action based on choice from validation list

  1. #1
    Registered User
    Join Date
    09-22-2009
    Location
    Norway
    MS-Off Ver
    Excel 2003
    Posts
    5

    Perform action based on choice from validation list

    Hi. I need help with VB code for this. In all the cells in column F I have a validation list with several predefined choices, but at the bottom of this list I want an "Other..." option, which when chosen, enables the user to enter a new string in that cell if none of the predefined did not match.

    Thanks in advance.
    Last edited by kjetiltb; 10-05-2009 at 04:59 AM. Reason: Solved!

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Perform action based on choice from validation list

    You may not need VB code for what you're asking...

    Data Validation allows you to present a list, but accept unlisted items.
    Example:
    Cells D1:D7 contain the list:
    Alpha
    Bravo
    Charlie
    Delta
    Echo
    Foxtrot
    Golf

    Select cell A1
    Data.Validation
    ...Allow: List
    ...Source: =$D$1:$D$7
    Select the Error Alert Tab...
    ...Style: Warning
    ...Title: Please confirm
    ...Error message: Item is not on the list. Accept the item anyway?
    Click OK

    With those settings, A1 will have a drop down list, but if a user simply enters
    an unlisted value, a confirmation to accept that value is displayed.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    09-22-2009
    Location
    Norway
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Perform action based on choice from validation list

    Thanks, Ron. It solves my problem, although not as elegantly as I originally wanted, since the user has to know that he's able to write directly into the cell even with the drop-down list present

    Thanks again!

    Kjetil

  4. #4
    Registered User
    Join Date
    09-22-2009
    Location
    Norway
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Perform action based on choice from validation list

    Actually, my problem was twofold; Ron gave me an answer I could use for one, but I also need to write to a cell in another worksheet if one specific chioce is selected.

    I have a validation list of computer components, and if they choose 'HDD' from the list, I want the system to automatically generate an incremented ID number for it. I've got the ID generation down; I just need to know how I can "fire" the applicable function based on the users choice.

    Kjetil

  5. #5
    Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    263

    Re: Perform action based on choice from validation list

    Hi,
    I 'm not very clear on your requirement.
    But tried to help,
    Please Login or Register  to view this content.
    Hope this helps.
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

  6. #6
    Registered User
    Join Date
    09-22-2009
    Location
    Norway
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Perform action based on choice from validation list

    Thanks, vijay2482. I've got an IF statement like the one you posted, but the problem is for the sub or function to start automatically as soon as the user has made his/her choice from the validation list. Since the validation list is not called from code but is a built-in function in Excel I don't have anywhere in the code to call the IF statement...

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Perform action based on choice from validation list

    I just need to know how I can "fire" the applicable function based on the users choice.
    You can use the Worksheet_Change event.

    For more info. on Events see: http://www.cpearson.com/excel/Events.aspx

  8. #8
    Registered User
    Join Date
    09-22-2009
    Location
    Norway
    MS-Off Ver
    Excel 2003
    Posts
    5

    Thumbs up Re: Perform action based on choice from validation list

    Excel(lent) The Worksheet_Change event solved my problem! Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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