Macro to adjust a textbox to the size of the text

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
2,398
Hi Everyone,

I've been playing around with activex text boxes and have found I can adjust the height as I type.
so what I would like is a bit of code that can adjust the textbox to one line bigger (or the size of the text i'm tying in

I have this bit of code that will resize the text box so I need someone to show me how to make it dynamic if possibleplease

this is what I have it triggers everytime you type into the textbox.

Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub TextBox1_Change()
    ActiveSheet.Shapes("TextBox1").Height = 300[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]End Sub[/FONT]
please help if you can thanks

Tony
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,559
Office Version
365
Platform
Windows
Maybe something like this:

Code:
Private Sub TextBox1_Change()
   TextBox1.Height = TextBox1.Height + 20
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,089,862
Messages
5,410,854
Members
403,331
Latest member
dignityy

This Week's Hot Topics

Top