+ Reply to Thread
Results 1 to 9 of 9

UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

  1. #1
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    Hello,

    I have a very basic userform that includes a multiselect listbox (listTopics) of 15 items in the list, using option checkboxes. I want the user to be able to select all that apply INCLUDING an "Other" item, which is the last item in the list selections. If the user chooses "Other", regardless of any other items selected, it enables a text box (txtboxOther). I would also like that textbox to appear grey in color, but change to white if "Other" is selected.

    Capture.PNG

    I have searched and found VBA code for topics on checkbox or radio button selections enabling textboxes, but limited information on a multiselect listbox selection enabling a textbox. Seems like it would be so common! But perhaps I'm just too much of a novice in design and coding.

    Any help would be immensely appreciated, so thank you in advance! I'm using Excel 2010.

    Chris

  2. #2
    Forum Contributor
    Join Date
    09-24-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    Try this for the Option checkbox click event...

    Please Login or Register  to view this content.
    Replace the names of the checkbox1 and textbox1 with your names for those.

  3. #3
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    Hi moonsaga,

    Thanks for the suggestion, but I think I misled you by use of the word "checkboxes". This is actually a ListBox set to MultiSelect so the user can select as many from the list as needed. Do you have another suggestion for using a listbox with multiselect?

    Any info is appreciate, thank you!

    Chris

  4. #4
    Forum Contributor
    Join Date
    09-24-2013
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    Try this.. (untested)

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    I tried it but still nothing. If I change your Click to Change, I get a little action on the background color, but opposite of what we'd expect and still nothing on enablement of the textbox as if it's set to True in Properties, then I can type in the field, False I cannot.

    I'm using ActiveX (not sure if that matters), but I think the multiselect may require some unique looping in the code or something. Not sure obviously. If you have other thoughts, I'd be willing to give it a go!

    Thanks so far!

    Chris

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    userform with listbox and textbox

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  7. #7
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    Thanks Andy!

    I haven't tried your code direction yet, but will likely give it a shot with another form with the same desired functionality. I stumbled on something in a search that I modified as follows and it seems to work so far, but your code looks more straightforward. If you happen to see this post and have an opinion if I'm breaking convention or was just plain lucky I'd be very interested. There seemed to be some mystery with the multiselectmulti option for listbox. I'm trying to learn by fire some integrity to what I'm building!

    Again appreciate the info. Take care.

    Private Sub frmBizContext_Initialize()
    txtBizContextOther.Enabled = False
    txtBizContextOther.Visible = False
    txtBizContextOther.Value = ""
    End Sub

    Private Sub listExpTopics_Change()
    If listExpTopics.Selected(14) = False Then
    txtBizContextOther.Value = ""
    txtBizContextOther.Enabled = False
    txtBizContextOther.Visible = False
    Else
    txtBizContextOther.Enabled = True
    txtBizContextOther.Visible = True
    End If
    End Sub

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    Nothing wrong with that code apart from the static value 14. If the list never changes then okay but if you add/remove items then you will need to alter that value every time.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  9. #9
    Registered User
    Join Date
    07-15-2013
    Location
    Arizona
    MS-Off Ver
    Excel 2016
    Posts
    64

    Re: UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)

    Ok, thanks for the specific feedback on the code, good to know.

    Apologies on the rule break...the second I hit post I realized I should have put the tags on it...will be more attentive next time.

    Appreciate it!

+ 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. [SOLVED] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. [SOLVED] Excel glitch? (Userform Textbox = Format, "Date")
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-13-2013, 01:47 PM
  3. [SOLVED] "Delete Selected" in Search Result listbox deletes first row, instead of selected row.
    By Faustus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2013, 02:11 AM
  4. [SOLVED] listindex=0 when first item selected in a multiselect listbox on a userform?
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-17-2013, 12:38 PM
  5. Can I "Enable Editing" using VBA on OPEN in Excel 2010
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-01-2011, 07:39 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