Search code examples
excelvbauserform

Removing the scroll bar on a list box in Excel VBA UserForms


I'm using a UserForm in Excel VBA and I have a combo box with style fmStyleDropDownList. I want to remove the horizontal scrollbar:

Keep in mind that this problem is somewhat similar to this one: Remove the scroll bar on a list box. In this post, the accepted solution states:

This can occur when you have the column width format property of the listbox set to something wide, then you size the control to the data, it will show the scroll bars.

To fix this, change the "Column Width" property under the format tab to something really small, then play around with this property and the size of the listbox control until you get it how you want, and no scroll bars are displayed.

So what I did is: I changed the ColumnWidths property to smaller values until the horizontal scroll bar disappears. However, this has the side effect that the drop down text has not enough width to be displayed as a whole as it is shown in the following Pictures (the Width and LastWidth property remain at 162):

  • Picture of my combo box with ColumnWidths of 50 pt. The scroll bar is still there. Instead of "abcdefghijklmn", only "abcdefghijkl" (without mn) is dislayed in the second row of the drop down menu and in the third row it says "something e" instead of "something else". I assume this is because the ColumnWidths property is set too small.
  • Picture of my Combo box with ColumnWidths of 18 pt. The scroll bar is gone (which is what I want). 18 pt is the biggest value I came up without having a scroll bar. But it now displays only a few (18?) points in any row of the drop down menu which is unacceptable to me.

Any ideas how to solve this?


Solution

  • As Siddharth Rout pointed out, the problem was due to multiple columns. Setting the ColumnCount property back to 1 solves this issue.