+ Reply to Thread
Results 1 to 3 of 3

Can't get combo box in user form to populate

  1. #1
    Registered User
    Join Date
    05-14-2015
    Location
    Tulsa, USA
    MS-Off Ver
    2013
    Posts
    2

    Can't get combo box in user form to populate

    Hi all,

    I'm building a user form to input data to a sheet. Everything works except the combo box, which won't populate. I've tried the forums here, Microsoft help, and YouTube, but I can't find anything wrong with the methods I've tried. I'm pretty new at this, so it's probably some obvious difference between the instructions and my code that I'm not noticing. Here's my original code:

    Please Login or Register  to view this content.
    When this didn't work, I tried a different style:

    Please Login or Register  to view this content.
    I've placed this code in "ThisWorkbook" and the form code module and I've tried commenting out the list index line in case it was causing problems. No matter what I've tried, the combo box is always blank. Any suggestions?
    Last edited by KDrew; 05-14-2015 at 07:10 PM.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Can't get combo box in user form to populate

    Hi KDrew and welcome to ExcelForum,

    Thank you very much for using CODE TAGS.
    Excellent job using 'Option Explicit'.

    There is nothing wrong with your code. The problem is your spelling.

    Try: Sub UserForm_Initialize()

    In the future, I recommend two things:
    a. Don't type in the names of UserForm routines. Let Excel do it automatically to prevent spelling errors.
    b. If a routine doesn't seem to work, put a breakpoint on the routine in the debugger and single step through it. That's how I knew about the spelling error. The breakpoint I set never got triggered.

    Here are a few debugger tips for the future:
    Debugger Secrets:
    a. Press 'F8' to single step (goes into subroutines and functions).
    b. Press SHIFT 'F8' to single step OVER subroutines and functions.
    c. Press CTRL 'F8' to stop at the line where the cursor is.
    d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
    e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
    output to the IMMEDIATE WINDOW.
    f. Select View > Locals to see all variables while debugging.
    g. To automatically set a BREAKPOINT at a certain location put in the line:
    'Debug.Assert False'
    h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
    if i >= 20 and xTV20 > 99.56 then
    Debug.Assert False
    endif
    i. A variable value will be displayed by putting the cursor over the variable name.

    Lewis

  3. #3
    Registered User
    Join Date
    05-14-2015
    Location
    Tulsa, USA
    MS-Off Ver
    2013
    Posts
    2

    Re: Can't get combo box in user form to populate

    Lewis,

    Thanks for the quick reply, that fixed it perfectly. Knew it was some stupid mistake. I did let Excel create the sub name, but I must have deleted the letter without noticing. I also ran through the first set of debugging tips but didn't understand what they were telling me. Appreciate the catch!

+ 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] Use vlookup to auto populate a combo box in user forms
    By katieshields in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2014, 09:45 AM
  2. How to populate a text box in the details form from a combo box
    By Lloyd Blankfein in forum Access Tables & Databases
    Replies: 0
    Last Post: 06-20-2013, 05:40 AM
  3. combo box user form code for two combo boxes
    By robert.begley1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2012, 02:25 PM
  4. 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
  5. help with user form and combo box
    By TechRetard in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-01-2011, 04:56 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