Horizontal scrolling on List Box controls

Published on June 4, 2012

The VBA UserForm List Box control automatically adds a vertical scrollbar when the number of lines exceeds what can be displayed. The same is not true for lines that exceed the width of the control, as shown in the image below.

CAD Training

To remedy this many developers will extend the width of the List Box control to encompass their longest lines. This can result in messy looking and very large dialogs that get in the way of other windows you want to view simultaneously. It is possible to add a horizontal scrollbar to a List Box control by editing the ColumnWidths property of the control. Making the ColumnWidth value greater than the Width value of the control will add a horizontal scrollbar.

CAD Training

After modifying the ColumnWidths property run the macro again and a horizontal scroll bar will be available for the List Box. Adjust the ColumnWidths property as necessary to accommodate your longest lines.

CAD Training

Like this article? Share it!

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Privacy Policy