how decrease and increase size of textbox on userform by autosize

Ali M

Active Member
Joined
Oct 10, 2021
Messages
330
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Hello
I have textbox1 on userform .I want wen write inside the textbox then should increase & decrease textbox1 based on filling inside textbox
this what I have but doesn't work

VBA Code:
Private Sub UserForm_Initialize()
    Set txtNew = Controls.Add("Forms.textbox1")
TextBox1.Left = 36
TextBox1.Top = 42
TextBox1.MultiLine = True
TextBox1.WordWrap = True
TextBox1.AutoSize = False
TextBox1.Width = 108
TextBox1.SetFocus
TextBox1.Height = 30
End Sub


before when write number




TEX.PNG


as you see first pictur contains empty after 00

should be like this just slight space in right and left not big space . like fit columns inside sheet

TEX1.PNG

thanks guys
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Perhaps something like this...

VBA Code:
Private Sub UserForm_Initialize()

    Dim txtnew As Control

    Set txtnew = Me.Controls.Add("Forms.textbox.1", "TextBox1")
    With Me.Controls("TextBox1")
        .Left = 36
        .Top = 42
        .MultiLine = False
        .WordWrap = True
        .AutoSize = True
        .Width = 108
        .SetFocus
        .Height = 30
    End With

End Sub
 
Upvote 0
Solution
really apologies for too delaying .!!!!🙏🙏🙏
honestly I don't note it :eek:
your solution work greatly .;)
many thanks :)
 
Upvote 0
No problems. You're welcome, I was happy to help. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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