View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default UserForm TextBox with fixed Width and dynamic Height

You could play around a bit with it, by adjusting the height by the number
of characters, but I doubt that you can be totally accurate as it depends
upon where the word breaks.

Private Sub TextBox1_Change()
With Me.TextBox1
.Height = Application.Min(Me.Height - 32, (Int(Len(.Text) /
Int(.Width / 4.7)) + 1) * 18)
End With
End Sub

should get you started on the idea, but you will need to play with the
variables to suit.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Soniya" wrote in message
oups.com...
Hello,

Can we have a multi line TextBox in a Userform with fixed width but the
height adjusting according to the length of text? Say if the textbox
contains text to be fit in five lines then adjust the height
accrdingly? also with a maximum height fixed, so that it may not be
more than the height of the userfom itself.

Thanks