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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

staticbob

Well-known Member
Joined
Oct 7, 2003
Messages
1,079
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
 

zoso

Well-known Member
Joined
Oct 23, 2003
Messages
725
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!
 

staticbob

Well-known Member
Joined
Oct 7, 2003
Messages
1,079
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
 

Satal Keto

New Member
Joined
Nov 21, 2005
Messages
12

ADVERTISEMENT

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.
 

staticbob

Well-known Member
Joined
Oct 7, 2003
Messages
1,079
Glad it helped . . . . . and I'm just trying to hit my 1000th post. LOL
 

Satal Keto

New Member
Joined
Nov 21, 2005
Messages
12

ADVERTISEMENT

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?
 

Satal Keto

New Member
Joined
Nov 21, 2005
Messages
12
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.
 

staticbob

Well-known Member
Joined
Oct 7, 2003
Messages
1,079
Not a problem mate, glad I could help... LOL

Bob

(I'm gonna save my 1000th for a genuine post !)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,117
Messages
5,857,482
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

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
Top