+ Reply to Thread
Results 1 to 20 of 20

How to use the UserForm Initialize event to Initialize 3 listboxes in the same userform

  1. #1
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    How to use the UserForm Initialize event to Initialize 3 listboxes in the same userform

    Good Day to all,

    So I have a UserForm which has 3 listboxes which I want populated with information from 3 separate sheets when the useform is loaded.

    I can populate one listbox easily, but when i try to do multiple listboxes in the same userform I run into problems

    The following is what I use to arrange listbox1 and populate listbox1

    Please Login or Register  to view this content.
    I have this code in a module

    This code to initialize the userform

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    This is what I came up with to accommodate my 3 listboxes

    Module one code

    Please Login or Register  to view this content.

    And my UserForm Utilize event

    Please Login or Register  to view this content.
    Can someone Please point out what i'm doing wrong as this is not working and i am officially stuck

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

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Do you other subs similar to Arrange_ListBox1 for the other listboxes?

    If you do you could just call all 3 subs from the Initialize event.
    If posting code please use code tags, see here.

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

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    The only thing you need to fill a ListBox is this.
    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.

  5. #5
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Re this quote from Norie
    If you do you could just call all 3 subs from the Initialize event
    could you give a short example of how to do this?

  6. #6
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Re bakerman2

    I only want the first 3 columns of the relevant sheet to be displayed alphabetically. I am thinking this code won't do that. Please correct me if I am wrong.
    Last edited by Pimp_mentality; 09-11-2016 at 10:19 PM.

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

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Please correct me if I am wrong.
    I'm correcting you cause you're wrong. What's the Resize for do you think?

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Pimp_mentality,
    Referencing Sheet by its CodeName makes a little complex for this one.
    You need to check "Trust access to the VBA project object model" see https://support.microsoft.com/en-us/kb/282830.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120
    Quote Originally Posted by bakerman2 View Post
    I'm correcting you cause you're wrong. What's the Resize for do you think?
    Yes it seems I am. I stand corrected sir

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

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Based on the original code try this.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Good day Norie

    I tried the above but received a runtime error 13 "type mismatch"

    I really don't know why

  12. #12
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Good Day bakerman2

    As I am also interested in the method you posted

    I tried the way you suggested (as i am genuinely interested in both methods) with no success. only listbox1 was populated but listbox2 and listbox3 did not populate

  13. #13
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    I'm confused, why not simply:
    Please Login or Register  to view this content.
    I don't understand why you seem to have the same code in a module and the userform

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

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED, scroll down and click Manage Attachments.

  15. #15
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    her is a sample of my form
    Attached Files Attached Files

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Please Login or Register  to view this content.
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    re kyle123 I did try that but only list box one populated, the others did not

  18. #18
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Re jindon,

    This method works great, the VsortM sub is one I m not accustomed to but I am examining and googling so i can understand better exactly what you did so I can utilize the method in other projects I am working on

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

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Just to show Kyle123's method (and mine's) actually does work.
    Attached Files Attached Files

  20. #20
    Forum Contributor
    Join Date
    10-03-2015
    Location
    Jamaica
    MS-Off Ver
    2013
    Posts
    120

    Re: How to use the UserForm Initialize event to Initialize 3 listboxes in the same userfor

    Hey guys thanks a millions for the help

    Much appreciative

+ 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 runs Initialize sub @ beginning of textbox AfterUpdate event w/out being called
    By chirp08 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-18-2016, 01:02 PM
  2. [SOLVED] How to deal with multiple sets of code in the Initialize Event of a userform
    By chin67326 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2015, 06:54 AM
  3. Userform - help with initialize
    By Macster in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-23-2009, 05:40 AM
  4. userform initialize
    By Patrick Simonds in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2006, 05:40 PM
  5. userform initialize
    By Patrick Simonds in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2006, 05:35 PM
  6. initialize userform, using a sub
    By natanz in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-22-2005, 01:35 AM
  7. UserForm Initialize event doesn't fire reliably
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-15-2005, 09:41 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