Expand cell height to match textbox

Mcfg007

New Member
Joined
Mar 10, 2018
Messages
45
How can I get the cells to expand with the size of a texbox. I am entering text and the Activex texbox is expanding with Multiple lines accordingly to the text, but after a period goes over other fields, How can I get the field cells to expand?
 
Perhaps something like this:-
Code:
Private Sub TextBox1_Change()
With TextBox1
    .AutoSize = True
    .MultiLine = True
    .WordWrap = True
    .TopLeftCell.RowHeight = TextBox1.Height
    .Width = 100 'Set as required
End With
End Sub

My textbox is in row 19 D to I

will this code work in the same way?
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I imagine so, Just alter the textbox width to an appropriate size (Like 400)
Its not the prettiest but it seems to work !!
 
Upvote 0
I imagine so, Just alter the textbox width to an appropriate size (Like 400)
Its not the prettiest but it seems to work !!

I meant to say, that this code does not seam to work. Any other suggestions? Anyone?
The question is how do I get a cell or a range of cells where a box is placed, to expand in height accordingly to the height of the text box once text is entered.
 
Upvote 0

It worked for the first TexbBox1 but for the second I had the code as follows but it didn't work. What am I doing wrong? Shows an error on lien .TopLeftCell of the bottom code for TexbBox2
Option Explicit
Private Sub TextBox1_Change()
With TextBox1
.AutoSize = True
.MultiLine = True
.WordWrap = True
.TopLeftCell.RowHeight = TextBox1.Height
.Width = 300 'Set as required
End With
End Sub

Private Sub TextBox2_Change()
With TextBox2
.AutoSize = True
.MultiLine = True
.WordWrap = True
.TopLeftCell.RowHeight = TextBox2.Height
.Width = 300 'Set as required
End With
End Sub
 
Upvote 0
I've just tried with another "TextBox" and I also have problems. I think it just the general Instability of ActiveX controls in sheets.
I don't think I can resolve it unfortunately.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top