+ Reply to Thread
Results 1 to 5 of 5

ComboBox Not Populating User Form

  1. #1
    Forum Contributor
    Join Date
    01-07-2020
    Location
    Columbus, Ohio
    MS-Off Ver
    2019
    Posts
    100

    Question ComboBox Not Populating User Form

    Hello. I am attempting to use a ComboBox that would autofill an existing Excel Form. Basically, I have it set where a user can select an existing entry by reference number. I am trying to set it up so when this is done the rest of the form autopopulates with the rest of the data associated with that reference number. I have run into some issue, however. The ComboBox allows you to select an existing record, but it is not autofilling the rest of the form. The code I am using is below:

    Private Sub cmbsearch_Change()
    cmbsearch.RowSource = "'CAP'!B2:B10000"
    Dim capname As Integer

    Exit Sub

    capname = cmbsearch.Value

    On Error Resume Next

    Me.txtbox1.Value = Application.WorksheetFunction.VLookup(capname, Sheets(“CAP”).Range("A2:Q10000"), 1, 0)

    Me.txtbox2.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 3, 0)

    Me.txtbox3.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 4, 0)

    Me.txtbox4.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 5, 0)

    Me.txtbox5.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 6, 0)

    Me.txtbox6.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 7, 0)

    Me.txtbox7.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 8, 0)

    Me.txtbox8.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 9, 0)

    Me.txtbox9.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 10, 0)

    Me.txtbox10.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 11, 0)

    Me.txtbox11.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 12, 0)

    Me.txtbox12.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 13, 0)

    Me.txtbox13.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 14, 0)

    Me.txtbox14.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 15, 0)

    Me.txtbox15.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 16, 0)

    Me.txtbox16.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 17, 0)

    Me.txtbox17.Value = Application.WorksheetFunction.VLookup(capname, Worksheets(“CAP”).Range("A2:Q10000"), 18, 0)

    End Sub

    Thanks in advance for any help you can provide. Please let me know if you need more information.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: ComboBox Not Populating User Form

    Missed the large yellow banner at the head of the page ?????????????
    You will get a quicker solution if you upload your workbook.
    Also read the forum rules, you will get you knuckles rapped if you do not enclose your code between code tabs # your code #
    torachan

  3. #3
    Forum Contributor
    Join Date
    01-07-2020
    Location
    Columbus, Ohio
    MS-Off Ver
    2019
    Posts
    100

    Re: ComboBox Not Populating User Form

    Apologies! I have attached my workbook with all data removed. No PII.
    Attached Files Attached Files

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: ComboBox Not Populating User Form

    Your code will not do anything as you have an 'Exit Sub' command on the third line.
    Try the attached the code is condensed and repetitive code is contained in the 'Module'
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    01-07-2020
    Location
    Columbus, Ohio
    MS-Off Ver
    2019
    Posts
    100

    Re: ComboBox Not Populating User Form

    You are my hero! Thank you so much!

+ 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] Populating user form combobox with range question
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2013, 05:06 PM
  2. Calling a user form initialize sub when entering the form to populate combobox...
    By regupnorth in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-02-2012, 07:24 AM
  3. Transfer User form data to a worksheet w.r.t. combobox item on the form
    By nm766 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2011, 12:43 PM
  4. transferring combobox value from one user form to populate combobox on another
    By smartphreak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2010, 10:12 PM
  5. Populating textbox from combobox options, then clearing form
    By karen000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2009, 10:47 AM
  6. Populating form text box on combobox selection.
    By samtwilliams in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2007, 04:38 AM
  7. Replies: 2
    Last Post: 02-07-2006, 11:10 PM

Tags for this Thread

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