Size a text box based on length

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to automatically adjust the height of the row attached to text box,
based on the length or amount of data in the text box. Any ideas?
 
Not sure what you mean, but does this work ?

Range("A1").Rows.AutoFit

NickHK
 
AutoFit will size to the max cell size, but does not include a text box that
is bound to a cell within the range. Thanks.
 
What do you mean by "adjust the height of the row attached to text box" then
?
If you mean adjust to the height of THAT cell, then maybe:

Private Sub CommandButton1_Click()
Dim DestCell As Range
Dim TestCell As Range

'Cell linked to Textbox
Set DestCell = Range("A1")

'Where it will not interfere with current column widths/row heights
Set TestCell = Range("U30")

With TestCell
.ColumnWidth = DestCell.ColumnWidth
.Value = DestCell.Value
.Rows.AutoFit
DestCell.RowHeight = .RowHeight
End With

End Sub

NickHL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top