+ Reply to Thread
Results 1 to 13 of 13

Listbox size shrinks when items are loaded

Hybrid View

efernandes67 Listbox size shrinks when... 03-30-2013, 06:04 AM
Norie Re: Listbox size shrinks when... 03-30-2013, 07:33 AM
efernandes67 Re: Listbox size shrinks when... 03-30-2013, 08:22 AM
Norie Re: Listbox size shrinks when... 03-30-2013, 08:25 AM
efernandes67 Re: Listbox size shrinks when... 03-30-2013, 09:01 AM
Norie Re: Listbox size shrinks when... 03-30-2013, 09:06 AM
efernandes67 Re: Listbox size shrinks when... 03-30-2013, 09:14 AM
Norie Re: Listbox size shrinks when... 03-30-2013, 09:24 AM
efernandes67 Re: Listbox size shrinks when... 03-30-2013, 09:30 AM
Norie Re: Listbox size shrinks when... 03-30-2013, 09:32 AM
efernandes67 Re: Listbox size shrinks when... 03-30-2013, 09:38 AM
Norie Re: Listbox size shrinks when... 03-30-2013, 10:00 AM
efernandes67 Re: Listbox size shrinks when... 03-30-2013, 10:37 AM
  1. #1
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Listbox size shrinks when items are loaded

    Hi,

    See attached file.

    I have a form with two listboxes 'Available' and 'Selected'.
    When I run the macro LoadList, the names of the named range 'myList' are loaded into the 'Selected' listbox, but the size of the listbox shrinks!

    What can I do, so both listsboxes remain the same size?


    Regards,
    Elio Fernandes
    Attached Files Attached Files
    Last edited by efernandes67; 03-30-2013 at 10:38 AM.

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

    Re: Listbox size shrinks when items are loaded

    Elio

    When I try and run LoadList I get a compile error.

    I can get it to run if I change Private to Dim for the variable declarations.

    However neither listbox changes size.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Listbox size shrinks when items are loaded

    Hi Norie,

    I just replaced the attached file. The file before, had 'Private' in procedure instead of 'Dim'.
    Can you check it again?

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

    Re: Listbox size shrinks when items are loaded

    Eh, I've already tried changing Private to Dim, see my previous post.

    I've tried the new file though and still no change in the size of the listboxes.

  5. #5
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Listbox size shrinks when items are loaded

    Norie,

    I just placed the excel file in another computer and the right listbox shrinks. See png file.
    You can see that the right listbox is more distant from OK button than the left listbox is from Cancel button.
    Attached Images Attached Images

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

    Re: Listbox size shrinks when items are loaded

    What exactly do you mean 'shrunk'?

    The 2 listboxes look exactly the same size to me, all the items from the worksheet are listed in the listbox on the right.

  7. #7
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Listbox size shrinks when items are loaded

    See the png file in my last post.

    You can see that the right listbox is more distant from OK button than the left listbox is from Cancel button

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

    Re: Listbox size shrinks when items are loaded

    Ah, looked at a bigger image and I see that.

    Not happening when I open the userform though, see attached.

    Is there any other code?
    Attached Images Attached Images

  9. #9
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Listbox size shrinks when items are loaded

    Please run the macro LoadList and show me the image with the items loaded.

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

    Re: Listbox size shrinks when items are loaded

    I've run the sub LoadList every time to open the form.

    Here's a picture.
    Attached Images Attached Images

  11. #11
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Listbox size shrinks when items are loaded

    The right listbox is empty!!! As you saw in my png file, there were some items loaded. Can you explain it to me?

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

    Re: Listbox size shrinks when items are loaded

    The problem is that VBA will try to resize the listbox so it doesn't show partial characters.

    I found the solution here and more info the help files.

    PS Why don't you use the userform's Initalize event to populate the listboxes?

  13. #13
    Registered User
    Join Date
    01-01-2005
    MS-Off Ver
    2007
    Posts
    368

    Re: Listbox size shrinks when items are loaded

    Thanks Norie, I used the the code in the link that you post it and it is working.

    I am not using userform's Initalize to populate the listboxes, because I am using the same userform in different situations in the same file. What I mean, is that I am using this userform as a template.

    Elio Fernandes

+ 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