Horizontal scrolling on List Box controls

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

Rod Wing

Rod is the Senior Systems Analyst at EnvisionCAD and has extensive experience in GIS, cartography, plotting, scanning, raster editing/manipulation, publishing, and file/data translations. He instructs MicroStation classes ranging from fundamentals to advanced.


2 comments on “Horizontal scrolling on List Box controls

  1. Dan Reply

    Very nice, but with Access 2013 it is not working for me.
    I have a listbox with the ColumnWidths set to “0.101cm;7cm” and the Width set to 4cm. I tryed different combinations of the 2 values, the influence was minimal, some millimeters at best.

    • Rod Wing Reply

      I don’t develop in Access so I don’t know what is going on there. The tip works when developing in MicroStation, Excel, and other VBA environments.
      Sorry I can’t be of more assistance.

Leave a Reply

Your email address will not be published. Required fields are marked *