Textbox question

RobbertH

Active Member
Joined
Apr 29, 2008
Messages
310
I have a textbox on an userform that will enable the user to write some comments on date entered in the userform. I set the size of the textbox so that it will match other control sizes in the form. However, the user might have to enter more text than would fit in the user form.
How do I set the textbox so that
1. the width will remain as preset
2. the height will increase when enter is pressed
3. All text remains visible at all times

Hope this is possible. I get it to work separately but not together.

Thanks for any help!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Something like this perhaps.

Change names as needed and check the Mod calculation, Mod in VBA slightly different from it's worksheet counterpart.
Code:
Private Sub TextBox1_Change()

   If (Len(TextBox1.Value) Mod 39) = 0 Then
      TextBox1.Value =TextBox1.Value& vbCrLf
   End If
End Sub
 
Upvote 0
Robert
I'm a little confused. I believe that I've given you the solution you asked for, and on my machine it works perfectly.
You can set the text box width to anything you like, on the userform, then when you run the userform up, and type into the textbox, as soon as the full width is reached, a new line starts. The textbox doesn't change width at all - just as you asked.
When the enter key is pressed a new line is started in the textbox, and the height of the box is increased by (about) the height of your font - which is also what you asked for!

I must be misunderstanding something here???????????????
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,792
Members
452,942
Latest member
VijayNewtoExcel

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