entering multiple lines in a textbox

sepandb

Board Regular
Joined
May 25, 2009
Messages
141
I have a textbox in my userform where anything typed in the box is entered into cell A2 in my worksheet. However, multiple lines of text are not properly displayed in my worksheet. I have enabled MultiLine and EnterKeyBehaviour in the properties window of the textbox so I can type multiple lines in my textbox. The problem is that when I press the button to enter the text from my txtbox to cell A2, the cell doesn't actually display the text in separate lines. It just places a square symbol in the place that enter should have been pressed and the text should have been split into separate lines.

How can I get the separate lines of text in my textbox to be properly displayed in a cell? Thanks for your help in advance..
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Try
Rich (BB code):
Private Sub CommandButton1_Click()
    [a2] = Replace(Me.TextBox1, vbCr, "")
End Sub
 
Upvote 0
No this doesn't seem to work. I seem to be getting the same problem, where cell A2 doesn't actually separate the lines of text the way it is separated in my textbox..
 
Upvote 0
Code:
Private Sub CommandButton1_Click()
    Cells(2, 1) = Replace(TextBox1.Value, VbCr,"")
End Sub
 
Last edited:
Upvote 0
Code:
Private Sub CommandButton1_Click()
    Cells(2, 1) = Replace(TextBox1.Value, VbCr,"")
End Sub

Thanks for the code. But this doesn't separate the lines of text if you write 2 lines in the textbox. It just shows one line of text separated by a strange square symbol where the space should have been...
 
Upvote 0
Try
Rich (BB code):
Private Sub CommandButton1_Click()
    [a2] = Replace(Me.TextBox1, vbCr, "")
    [a2].WrapText = True
End Sub
 
Upvote 0
Thanks for the code. But this doesn't separate the lines of text if you write 2 lines in the textbox. It just shows one line of text separated by a strange square symbol where the space should have been...

Works for me... Strange Indeed..

I'm using Excel 2003 though, not sure if that's an issue..
 
Upvote 0
Works for me... Strange Indeed..

I'm using Excel 2003 though, not sure if that's an issue..


I am using 2003. Maybe the fact that I left out some details in my initial description changed a few things. The cell that I am pasting to is not static. Depending on how big my spreadsheet becomes, it is either higher or lower on the spreadsheet. It will always be in Column A, but the row number changes. I have a declared variable called Finalrow, which finds the last row of data in my spreadsheet. The cell that I want to paste to would be ("A" & Finalrow + 2), so 2 rows below my 'FINALROW'.

I'm not sure if that changes anything. I assume the code you gave me should work despite this, as I modified the code appropriately.

I enter text into my textbox, press enter to start another line and enter more text into the box. But when it gets pasted to the cell in the worksheet, it is all in one line. Hopefully this post has cleared a few things up.

Thanks for all of your time already. I really appreciate it
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

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