Getting a listbox on a userform to scroll

Zakkala

Active Member
Joined
Nov 12, 2004
Messages
254
Hiya,

I've got a userform that pops up when a button is clicked. It has a listbox with two columns, the second of which is populated with the output of an evaluate formulae in the initialize code.

My problem is that the output of this formula is usually a lengthy text string which means the content of the second column is wider than the column itself and no scroll bar appears to allow you to scroll and see it all. I've made the column wider, but realistically I need the ability to scroll.

I'm not sure whether there's some way of prompting the listbox to have a scroll bar or if I need to attach one, and if I need to attach one I could do with some pointers as I've never used one before and am not sure how to get it to work (had a bit of a play around but it wasn't very successful!) - can anyone offer any advice please please?

Cheers,

mel.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
You may try adding a TextBox control with the MultiLine and WordWrap properties set to true and the ScrollBars set to 2 or 3. Then, in the Click event of the ListBox create the association between the value of the second column in the selected item in the list to the value of the TextBox control. Like that the text in the second column of the selected item of the ListBox will be entirely available to the user - something like:
Code:
Private Sub ListBox1_Click()
    TextBox1.Value = ListBox1.Column(1, ListBox1.ListIndex)
End Sub
 
Upvote 0
Thanks - I have indeed now gone down the textbox root; figured it was easier to re-engineer the entire userform rather than faff about with the listbox any further!
 
Upvote 0
As as matter of interest if you increase the column Widths (like:- 100,100)in the ListBox Properties, you will probably get a Horizontal scrollbar to meet your needs.
Mick
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top