ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Size a text box based on length (https://www.excelbanter.com/excel-programming/385638-size-text-box-based-length.html)

Troubled User

Size a text box based on length
 
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?

NickHK

Size a text box based on length
 
Not sure what you mean, but does this work ?

Range("A1").Rows.AutoFit

NickHK

"Troubled User" wrote in message
...
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?




Troubled User

Size a text box based on length
 
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.

"NickHK" wrote:

Not sure what you mean, but does this work ?

Range("A1").Rows.AutoFit

NickHK

"Troubled User" wrote in message
...
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?





NickHK

Size a text box based on length
 
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

"Troubled User" wrote in message
...
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.

"NickHK" wrote:

Not sure what you mean, but does this work ?

Range("A1").Rows.AutoFit

NickHK

"Troubled User" wrote in

message
...
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?








All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com