TextBox on Userform carriage return/word wrap problem

ScottNiag

Active Member
Joined
Sep 3, 2002
Messages
260
Hi:

2 Questions:

I have a text box on a userform where I want to store comments that the user can enter. The problem is, when I hit Enter after typing something into the textbox, , the cursor does not go to the next line, but instead the text box loses the focus, which instead goes to a button I've put on the form. I want to be able to enter text in paragraphs etc, so how can I do that? I can find no property of the text box from the Proerties Window which corresponds to this problem.

Secondly, I want to be able to store this text from the userform on the worksheet. I discussed a few weeks ago the possibility of storing the comments as an Excel Comment, but someone suggested that I just store the text in a cell, particularly as I think comments have a limited capacity. Can I hold text in a cell and still retain the paragraphs etc? I also want to be able to allow the user to append to this comment. When an "Add Comment' button on the worksheet is clicked, the userform is loaded, and the text from the cell is placed into the text box, (hopefully with paragraphs intact), then the focus of the textbox go to the bottom of the text so far, so that additional comments can be made.

Any help greatly appreciated.

Overall, what I am trying to accomplish is to take a list of 2,000 clients, arranged in rows of course, and have ONE column devoted to storing these comments. The user will click on any cell in that particular client's row, then click 'Add Comment', and see the comments so far and append if necessary.

Thanks.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
To achieve the effect of creating new lines of text, "paragraph-looking" text, etc. in a TextBox when you hit Enter while entering text into a TextBox, set the TextBox's EnterKeyBehavior property to True *AND* set its MultiLine property to True.

A comment can hold about 32,000 characters of text, or about 255 lines.

You can enter the TextBox text into a cell like so:

Private Sub CommandButton1_Click()
Range("A1").Value = TextBox1.Text
End Sub


You can append an existing cell value with an added text like so:

Private Sub CommandButton2_Click()
Range("A1").Value = Range("A1").Value & TextBox1.Text
End Sub


You can populate a userform's TextBox with a cell's value like so:

Private Sub UserForm_Initialize()
TextBox1.Text = Range("A1").Value
End Sub


In the worksheet cell, you will see little squares that represent where the user hit the Enter key in the userform TextBox. Those are most likely ascii character 13 and normal given what you are asking for.
 
Upvote 0
Sorry for bumping up the old thread but couldn't resist replying. It is still valid at onset of 2014 :)
 
Upvote 0
Oct 2014 !

I couldn't resist joining and saying that this is still a really helpful little piece of information.

It's simple things like this that are so hard to discover.
 
Upvote 0

Forum statistics

Threads
1,213,517
Messages
6,114,089
Members
448,548
Latest member
harryls

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