Adding a scroll bar to a label
I have a label on a userForm and the data within it is in list form. The data is longer than the label. Without expanding the label, is there a way to add a scro开发者_开发知识库ll bar to it? Or is there another option? Basically I want a box that does not have a scroll bar unless the list is longer than the box, then there's a scroll bar.
Using Excel vba userForm
You can used a textbox styled to look like a label. Set it to multiline with scrollbars set to vertical. Scrollbars will only show up if the content exceeds the size.
You can't have scroll bar for label, instead a textbox can be used. Set textbox with "Enabled" and "Locked" properties as"true". User will then have a scrollable and noneditable view
For vertical scrolling, set "WordWrap" and "MultiLine" to True
Now you could view the scroll bar on tapping the textbox. If you want the scroll bar to be visible by default, on the form load event we need to set the focus of textbox as below:
Private Sub UserForm_Initialize() errorText.SetFocus End Sub
精彩评论