Copying multiline textboxes from userform to worksheet cell

L

Leighton Harker

I have a userform that contains a multiline textbox with wordwrap.
This displays correctly on the userform.

I want to copy the contents of the textbox back into a worsheet cell
as follows

ActiveCell.Offset(0, 5).Value = frmAddIssue.TextBox2.Value

This works okay but the line breaks are displayed as 'square box'
characters in the cell - is there a way to avoid this?

Thanks in advance
Leighton
 
T

Tom Ogilvy

ActiveCell.Offset(0, 5).Value = Application.Substitute( _
frmAddIssue.TextBox2.Value,chr(13)," ")

or if you have Excel 2000 or later, you can use the VBA replace function in
lieu of the worksheet function substitute.

Substitute will work in all versions of Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top