+ Reply to Thread
Results 1 to 4 of 4

Userform: Enter combobox value unless textbox contains data

  1. #1
    Registered User
    Join Date
    04-26-2006
    Posts
    10

    Userform: Enter combobox value unless textbox contains data

    Hi again. This forum has been invaluable.

    I'd like to know the piece of code for a userform that would enter the combobox value by default unless any data is present in a textbox (as a "specify other" choice not present in the combobox).
    Thanks!!!!

  2. #2
    Tom Ogilvy
    Guest

    Re: Userform: Enter combobox value unless textbox contains data

    With userform1.Combobox1
    .Style = fmStyleDropDownCombo
    .MatchRequired = False
    .Value = "Specify Other"
    End With

    --
    Regards,
    Tom Ogilvy


    "smplogc" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi again. This forum has been invaluable.
    >
    > I'd like to know the piece of code for a userform that would enter the
    > combobox value by default unless any data is present in a textbox (as a
    > "specify other" choice not present in the combobox).
    > Thanks!!!!
    >
    >
    > --
    > smplogc
    > ------------------------------------------------------------------------
    > smplogc's Profile:

    http://www.excelforum.com/member.php...o&userid=33887
    > View this thread: http://www.excelforum.com/showthread...hreadid=537875
    >




  3. #3
    Registered User
    Join Date
    04-26-2006
    Posts
    10
    Thanks Tom!

    I think I didn't explain myself clearly though. I'm talking about a userform with a combobox, a textbox, and an "Enter" command button. I want the commandbutton to always enter the combobox value unless the textbox contains data that was inputted by the user.

  4. #4
    Tom Ogilvy
    Guest

    Re: Userform: Enter combobox value unless textbox contains data

    Private Sub Commandbutton1_click()
    Dim sh as Worksheet
    set sh = Worksheets("Sheet1")
    With Userform1
    if .Textbox1.Text = "" then
    sh.Range("B9").Value = .Combobox1.Value
    else
    sh.Range("B9").Value = .Textbox1.Text
    end if
    End With
    End Sub

    --
    Regards,
    Tom Ogilvy

    "smplogc" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Thanks Tom!
    >
    > I think I didn't explain myself clearly though. I'm talking about a
    > userform with a combobox, a textbox, and an "Enter" command button. I
    > want the command button to always enter the combobox value unless the
    > textbox contains data that was inputted by the user.
    >
    >
    > --
    > smplogc
    > ------------------------------------------------------------------------
    > smplogc's Profile:

    http://www.excelforum.com/member.php...o&userid=33887
    > View this thread: http://www.excelforum.com/showthread...hreadid=537875
    >




+ 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