Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

horizontal scrollbar in listbox control 1

Status
Not open for further replies.

RobBroekhuis

Technical User
Oct 15, 2001
1,971
US
Hi,
I'm fairly new to VBA - please excuse me if this is a FAQ.
In a userform I am building for an Excel application, I am using a listbox containing several short entries. To my dismay, Excel keeps displaying a horizontal scrollbar, even though the listbox is more than adequately sized to display all of the entries. I have to make the listbox about twice as wide as the widest entry to eliminate the scrollbar. Is there any simple reason/solution for this?
Thanks
Rob
 
If you specify a columnwidth that is within 2 points of the listbox width, the scroll bar appears. I guess that the width of the listbox border is 1 point so anything greater than listbox.width-(2 * border width) would be deemed to be too wide for the list box (even though ther data may not be).
If you do not specify the columnwidth or make the columnwidth < listbox.width -2 the scroll bar does not seem to appear.

Bizarrely, it does not appear to be based on the size of the data - Good ol' Bill!!

M :)


 
Thanks Mossoft, for pointing me in the direction of the &quot;columnwidths&quot; property. I figured I didn't need it because Excel would calculate it for me - turns out the minimum calculated column width is 1 inch - I had to adjust it down to 40 points.
Now it works!
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top