Multiple lines in a text box

Satal Keto

New Member
Joined
Nov 21, 2005
Messages
12
What i want to do is get more than one line of text in a text box.

I know that the following code will change the text of a text box to Hello
Code:
Private Sub CommandButton1_Click()
TextBox1.Text = "Hello"
End Sub

But what i would like to do is get it to change the text of the text box to...
Hello
World

I know that i can do a more than one line in a MsgBox by using the code
Code:
Private Sub CommandButton1_Click()
MsgBox "Hello" & vbCrLf & "World"
End Sub
But you can't use & vbCrLf & like that in a text box.

Does anyone have any ideas of how i would be able to achieve this?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi Satal, welcome to the board !!!

This is from the macro recorder !

Code:
 ActiveSheet.Shapes("Text Box 1").Select
 Selection.Characters.Text = "Hello" & Chr(10) & "World" & Chr(10) & ""

Bob
 
Upvote 0
I'm not 100% on this, but if you right click the text box and select Properties, there will be a field along the lines of 'allow multiple line' - that needs to be changed to Yes.

HTH!
 
Upvote 0
Ooops, I stooopidly assumed you were working with a standard textbox.

Zoso is spot on, there is a multiline property, when set to true your messagebox code will work fine.

Bob
 
Upvote 0
Wow that has to be the quickest i have got an answer on a message board, let alone one which actually helped me :D
I changed the code slightly to
Code:
Private Sub CommandButton1_Click()
TextBox1.Text = "Hello" & Chr(10) & "World" & Chr(10) & ""
End Sub

I kept getting the paragraph symbol, which i didn't realise was because i didn't have the multiple line set to true.

So thank you staticbob and thank you ZOSO.
 
Upvote 0
Now maybe if i replied to that asking for a reply for something maybe you could send me another reply which would take you up another post?

Or would that be against the rules?
 
Upvote 0
Ok well i thought it might have been worth a try, good thing i checked before starting making random convosation to try and get your posts up.
But anyway thanks for the help with the new lines ive spent ages trying to figure that out.
 
Upvote 0
Not a problem mate, glad I could help... LOL

Bob

(I'm gonna save my 1000th for a genuine post !)
 
Upvote 0

Forum statistics

Threads
1,212,099
Messages
6,105,958
Members
447,987
Latest member
rasika_99

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