+ Reply to Thread
Results 1 to 9 of 9

List box not displaying 1st or 2nd option

  1. #1
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    List box not displaying 1st or 2nd option

    I have a user form with two list boxes. When I show the user form, I want to highlight the 2nd option on the ActivityList and the 3rd option on the MonthList. When the form is displayed, no options are selected for the ActivityList but the MonthList is correct?

    Please Login or Register  to view this content.
    Thanks in advance

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: List box not displaying 1st or 2nd option

    Try putting the code in the UserForm's Initialize event.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: List box not displaying 1st or 2nd option

    Thanks for your reply. I am not sure I am putting that code in the right place because it is not working? If I right click the userform and select view code, this is what I have:

    HTML Code: 
    Thank You.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: List box not displaying 1st or 2nd option

    It's in the right place, but doesn't have the right name.

    It should be Private Sub UserForm_Initialize, you don't replace UserForm with the name of the form.

  5. #5
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: List box not displaying 1st or 2nd option

    I changed the code but still not working? I have attached a sample file.

    Thank you.
    Attached Files Attached Files

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: List box not displaying 1st or 2nd option

    reverse the commands. also you have misspelled Initialize ;-)
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: List box not displaying 1st or 2nd option

    Oops, spelling error - it should be Initialize.

    Mind you the code will still not work because you've set the ControlSource for each combobox to a cell on the worksheet.

    If you remove the ControlSources you can use code to put the selected values in the cells.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: List box not displaying 1st or 2nd option

    Thanks so much. Works perfectly and I learnt a lot!

  9. #9
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: List box not displaying 1st or 2nd option

    On my user form, I have a few option buttons within a frame. I use [If Then] to allocate the selection to a cell range:

    Please Login or Register  to view this content.
    What code would I use for option buttons so the cell address changes as I change my selection on the user form?

    Thank 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