+ Reply to Thread
Results 1 to 4 of 4

how to set commandbutton.enabled=true with conditions for both combobox and textbox <> ""

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    Shanghai, China
    MS-Off Ver
    Excel 2016
    Posts
    22

    how to set commandbutton.enabled=true with conditions for both combobox and textbox <> ""

    I have a userform with one combobox, one textbox and one commandbutton, trying to figure out how to set commandbutton.enabled=true only if only there're contents in both combobox and textbox (<>""). I've tried:
    ----------------------------------------
    Private Sub Textbox1_Change()
    If TextBox1.Text <> "" And UserForm1.ComboBox1.Text <> "" Then
    CommandButton1.Enabled = True
    Else
    CommandButton1.Enabled = False
    End If
    End Sub
    ---------------------------------------
    But when user fill-in data in textbox, then select content from combobox, it doesn't work, only when user fill-in more data in textbox it works.
    Thanks in advance.

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: how to set commandbutton.enabled=true with conditions for both combobox and textbox <>

    try this
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: how to set commandbutton.enabled=true with conditions for both combobox and textbox <>

    Try something like this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    05-23-2013
    Location
    Shanghai, China
    MS-Off Ver
    Excel 2016
    Posts
    22

    Re: how to set commandbutton.enabled=true with conditions for both combobox and textbox <>

    awesome! exactly solved my problem, thanks both of 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