View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default transferring multiline text from userform to worksheet - line break problem



Private Sub CommandButton1_Click()
Set LR = Worksheets("Deposits").Range("A65000").End(xlUp)
LR.Offset(0, 3).Value = Replace(TextBox1.Text,chr(13),"")
TextBox1.Text = ""
UserForm4.Hide
End Sub

Click in the textbox and do Ctrl+V

or program the mousedown event.

--
Regards,
Tom Ogilvy


"Paul" wrote in message
oups.com...
Hi all,

I have set up a program with which information on a userform is
transferred to a worksheet. I have a problem with multiline text.

For the checkbox I have set the multiline text property to "true". A
user adds an address in the textbox that consists of 4 lines. The
following macro transfers the text to a worksheet when the OK button is
pressed (it finds the last cell, picks the line below that (LR) and
prints the text on that row in the third column from the left:

Private Sub CommandButton1_Click()
Set LR = Worksheets("Deposits").Range("A65000").End(xlUp)
LR.Offset(0, 3).Value = TextBox1.Text
TextBox1.Text = ""
UserForm4.Hide
End Sub

This works like a charm, except when I look in the worksheet the text
will look like this:

(name) []
(street) []
(city, state, zip) []
(country)

The "[]" represent the little squares that indicate a line break. For
some reason I just can't seem to find a way to get rid of them.

Is there a property for the cell that will get rid of the squares, or
perhaps a macro?

A second question about this userform: is there also a way to allow a
user to rightclick and paste the address in the textbox (copied from
another application)? If I rightclick now in the textbox, nothing
happens.

Thanks so much for your help!
Paul