+ Reply to Thread
Results 1 to 6 of 6

Userform - Combobox

Hybrid View

  1. #1
    Registered User
    Join Date
    12-26-2017
    Location
    New Hampshire, USA
    MS-Off Ver
    2016
    Posts
    18

    Userform - Combobox

    Hello,

    I'm fairly new in Excel and trying to create an userform to fill a table.
    I have 1 combobox and 4 textboxes to fill a table and right now I'm only able to fill the first row of the table. But, I am still trying to fill the other rows in table based on my combobox selection. Please find attached the SS.excel.jpg

    What I'm trying to do?

    1. Select "Motorcycles"
    2. Fill 4 cells in userform (Percent of ADT etc.)
    3. Add these values to table (C12, D12, E12, F12 respectively)
    4. Select "Passenger Cars" (2nd option in my combobox)
    5. Fill again the 4 cells in userform (Percent of ADT etc.)
    6. Add these values to table (C13, D13, E13, F13 respectively)

    Could you please help me to do that?

    Thank you very much in advance.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Userform - Combobox

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    12-26-2017
    Location
    New Hampshire, USA
    MS-Off Ver
    2016
    Posts
    18

    Re: Userform - Combobox

    Thanks for your answer. I uploaded a sample file.
    Attached Files Attached Files

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Userform - Combobox

    Here's your form code for Form2

    Private Sub CmdAdd2_Click()
    Dim whatrow As Long
     
     With Worksheets("Traffic")
        On Error Resume Next
        whatrow = Application.Match(ComboBox1.Value, .Columns(2), 0)
        On Error goto 0
        If whatrow > 0 Then
            .Cells(whatrow, "C").Value = TextBox1.Value
            .Cells(whatrow, "D").Value = TextBox2.Value
            .Cells(whatrow, "E").Value = TextBox3.Value
            .Cells(whatrow, "F").Value = TextBox4.Value
        Else
            MsgBox ComboBox1.Value & " Not found"
        End If
     End With
    End Sub
    
    Private Sub CmdClear2_Click()
    TextBox1 = ""
    TextBox2 = ""
    TextBox3 = ""
    TextBox4 = ""
    End Sub
    
    Private Sub CmdClose2_Click()
    Unload Me
    End Sub
    
    Private Sub ComboBox1_Change()
    Dim whatrow As Long
     
     With Worksheets("Traffic")
        On Error Resume Next
        whatrow = Application.Match(ComboBox1.Value, .Columns(2), 0)
        On Error goto 0
        If whatrow > 0 Then
            TextBox1.Value = .Cells(whatrow, "C").Value
            TextBox2.Value = .Cells(whatrow, "D").Value
            TextBox3.Value = .Cells(whatrow, "E").Value
            TextBox4.Value = .Cells(whatrow, "F").Value
        Else
            TextBox1.Value = ""
            TextBox2.Value = ""
            TextBox3.Value = ""
            TextBox4.Value = ""
        End If
     End With
    End Sub

  5. #5
    Registered User
    Join Date
    12-26-2017
    Location
    New Hampshire, USA
    MS-Off Ver
    2016
    Posts
    18

    Re: Userform - Combobox

    I've been struggling with this during 2 days, you are great Mike!
    Thank you so much!

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Userform - Combobox

    No problem there a many other ways to do this also.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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] Userform: Change Combobox list based on a second ComboBox selection
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-11-2016, 03:45 PM
  2. ComboBox values source being changed based on another combobox selection in a UserForm
    By stephenanderson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2016, 11:12 PM
  3. [SOLVED] Populate data from a Combobox in a UserForm into a combobox in another UserForm
    By johnw993 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2015, 04:32 AM
  4. Userform Combobox to populate form: Can I change the order of the columns in the combobox?
    By CraigWiggins in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2014, 12:14 PM
  5. [SOLVED] Make combobox list options dependant on selection in another combobox within a userform
    By Vladimir_Dobvchenko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-23-2013, 05:30 AM
  6. [SOLVED] send data from userform combobox to userform combobox
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-18-2013, 04:47 PM
  7. [SOLVED] Excel Userform: Populate other controls (i.e. textbox & combobox) based on combobox select
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2013, 04:50 PM

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