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?
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

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 !)
 

Watch MrExcel Video

Forum statistics

Threads
1,118,821
Messages
5,574,515
Members
412,599
Latest member
Schu94
Top