+ Reply to Thread
Results 1 to 8 of 8

comboboxes in user form aren't init at the first Initialize

  1. #1
    Registered User
    Join Date
    10-09-2019
    Location
    China
    MS-Off Ver
    365
    Posts
    19

    Unhappy comboboxes in user form aren't init at the first Initialize

    Hello together,
    I've a user form which has 2 comboboxes. One with adItems and one with list range. Both aren't filled when i start the form.
    My OK Button, which print the fields into the sheet, calls also the UserForm to initialize agian (to have an empty form again).
    Once i clicked the OK button, the combo boxes are loaded with the correct information. Idk whether i can actually point understandable to my issue.
    The Point is, the second init after i clicked OK button works, but for my understanding nothing different happen in the first init.

    Capture.JPG

    Next Pic shows the combobox after i clicked either OK Button or Clear Button
    Capture111.JPG

    Here's the Code:

    Please Login or Register  to view this content.
    Does anyone has an idea?

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: comboboxes in user form aren't init at the first Initialize

    This should do the trick.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    10-09-2019
    Location
    China
    MS-Off Ver
    365
    Posts
    19

    Re: comboboxes in user form aren't init at the first Initialize

    bakerman2,
    It does. Thank you Since I'm not that expert in vba (obviously), could you explain the difference?

    Andi

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: comboboxes in user form aren't init at the first Initialize

    Userform_Initialize is a standard procedure for EVERY userform, regardless the name of the form.

  5. #5
    Registered User
    Join Date
    10-09-2019
    Location
    China
    MS-Off Ver
    365
    Posts
    19

    Re: comboboxes in user form aren't init at the first Initialize

    Understood this but why it works after click the OK-Button? Here was also called Userform1_Init.... ?

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: comboboxes in user form aren't init at the first Initialize

    That's because you call the Userform1_initialize sub (which is the correct name) but it's only the Userform_Initialize event (without the 1) which fires automatically on opening any form.

    Userform1_initialize is just seen as a regular procedure, not as a Userform event code.

  7. #7
    Registered User
    Join Date
    10-09-2019
    Location
    China
    MS-Off Ver
    365
    Posts
    19

    Re: comboboxes in user form aren't init at the first Initialize

    Ok, got it. Thank you very much for the hint and the explanation.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: comboboxes in user form aren't init at the first Initialize

    You're welcome and thanks for rep+.

+ 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. Simple User form initialize and close
    By T 520 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2015, 02:47 PM
  2. User form on initialize to recall last entry from Excel Sheet
    By maip.kewa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2014, 07:16 PM
  3. [SOLVED] Calling User form Initialize: A way to display certain tab based on which sub called?
    By emilyloz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2013, 10:06 AM
  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. named range to populate default textbox value in User form-initialize
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-04-2012, 09:08 AM
  6. User Form Initialize Event Issues
    By Randy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-04-2005, 07:30 AM
  7. Closing user form in Initialize macro?
    By Don Wiss in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2005, 04:06 AM

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