B
BigPig
Hello all,
Is it possible to 'textwrap' an entry in a listbox so that if the length of
text exceeds the width of a listbox, it wraps/continues in the row beneath?
Example: I have a spreadsheet where a listbox resides. With the list box
there is a commandbutton that will enter the text of a textbox into the
listbox via additem.
I have managed to make it work by using the mid and len worksheet functions
where if the text length exceeds the width of 42 characters (close to the
length of the listbox):
Dim txt1 As String
Dim txt2 As String
Dim txt3 As String
txt1 = "Plyr 1: " & TextBox1.Text
Worksheets("sheet2").Range("a21") = txt1
txt2 = Worksheets("sheet2").Range("h22").Text
txt3 = Worksheets("sheet2").Range("h23").Text
ListBox1.AddItem (txt1)
If txt2 <> "" Then
ListBox1.AddItem (txt2)
End If
If txt3 <> "" Then
ListBox1.AddItem (txt3)
End If
I picked the length of 42 because I typed in 1thru 60 to see how many would
fit. I know that not all characters are the same length, but this seems to
work for the most part.
I have to think there is a better way. Is there?
Thanks.
Is it possible to 'textwrap' an entry in a listbox so that if the length of
text exceeds the width of a listbox, it wraps/continues in the row beneath?
Example: I have a spreadsheet where a listbox resides. With the list box
there is a commandbutton that will enter the text of a textbox into the
listbox via additem.
I have managed to make it work by using the mid and len worksheet functions
where if the text length exceeds the width of 42 characters (close to the
length of the listbox):
Dim txt1 As String
Dim txt2 As String
Dim txt3 As String
txt1 = "Plyr 1: " & TextBox1.Text
Worksheets("sheet2").Range("a21") = txt1
txt2 = Worksheets("sheet2").Range("h22").Text
txt3 = Worksheets("sheet2").Range("h23").Text
ListBox1.AddItem (txt1)
If txt2 <> "" Then
ListBox1.AddItem (txt2)
End If
If txt3 <> "" Then
ListBox1.AddItem (txt3)
End If
I picked the length of 42 because I typed in 1thru 60 to see how many would
fit. I know that not all characters are the same length, but this seems to
work for the most part.
I have to think there is a better way. Is there?
Thanks.