+ Reply to Thread
Results 1 to 4 of 4

Force Display of Userform Listbox Vertical Scroll Bar

  1. #1
    Registered User
    Join Date
    02-24-2022
    Location
    Ozaukee County, Wisconsin, USA
    MS-Off Ver
    Office 365 and Office 2013
    Posts
    19

    Force Display of Userform Listbox Vertical Scroll Bar

    Dear Forum,

    I'm trying to force a listbox on an Excel 365 userform to display the vertical scrollbar by default. This is due to the fact that when my workbook shows the form on different monitors, sometimes the vertical scrollbar doesn't show, even when there are data below the visible area.

    I have researched many postings on the web and on this forum, but haven't found success. My best guess is that I need an API call, similar to the code below. However, what I have tried isn't working, because I need to get the hWnd of the listbox itself, which I can't seem to do. I'm not super-familiar with using API calls in VBA, which I'm sure is part of the problem. Though I have used them from time to time.

    Does anyone have any insight on this?

    This is the code I have put in the header of the Userform module.
    Please Login or Register  to view this content.
    And I tried to set the hWnd using this code, which won't compile, and lists the hwnd member as the problem.
    Please Login or Register  to view this content.
    Any help would be much appreciated. This thread has NOT been cross-posted.

    Thanks!

    Brian

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,545

    Re: Force Display of Userform Listbox Vertical Scroll Bar

    ActiveX controls embedded in a Userform have no handles in VBA world. Consequently, the Win API is unlikely to help. In addition, the ListBox does not have a ScrollBars-like property (such as in TextBox or Frame controls) that allows you to force scroll bars to be visible.
    One solution would be to put the ListBox in a Frame and display the Frame control's scroll bar. But this will require some extra programming work to achieve an effect similar to the ListBox itself.

    Artik

  3. #3
    Registered User
    Join Date
    02-24-2022
    Location
    Ozaukee County, Wisconsin, USA
    MS-Off Ver
    Office 365 and Office 2013
    Posts
    19

    Re: Force Display of Userform Listbox Vertical Scroll Bar

    Got it. Thanks, Artik.

    Brian

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,545

    Re: Force Display of Userform Listbox Vertical Scroll Bar

    I've never faced your problem, so the suggestions below are blindfolded shots.
    Try different ways to "shake" the ListBox control. E.g.
    1. Decrease the height of the control to 0.75, and then revert to the original height.
    2. Similarly, just increase the height to eg 500 and restore.
    3. Hide and show the control.

    Use DoEvents and/or Me.Repaint for all these activities. See if there is a difference when you "shake" the control in the Userform_Initalize and Userform_Activate events. Or maybe the ListBox1_Enter event?

    Artik

+ 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 Listbox mouse scroll vba
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2018, 04:21 AM
  2. [SOLVED] Display column entries in row as vertical entries in a userform listbox
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-22-2016, 08:10 AM
  3. How do I get the scroll distance of a userform listbox scroll bar...
    By Rob Frankham in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-31-2014, 04:23 PM
  4. Replies: 0
    Last Post: 07-24-2012, 04:47 AM
  5. Force Display of Vertical Scroll Bars
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-04-2009, 12:55 PM
  6. Force textbox vertical scroll position to Top after value change
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2009, 05:16 PM
  7. Replies: 1
    Last Post: 08-22-2005, 02:05 PM

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