ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying multiline textboxes from userform to worksheet cell (https://www.excelbanter.com/excel-programming/311433-copying-multiline-textboxes-userform-worksheet-cell.html)

Leighton Harker

Copying multiline textboxes from userform to worksheet cell
 
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

Tom Ogilvy

Copying multiline textboxes from userform to worksheet cell
 
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.
--
Regards,
Tom Ogilvy

"Leighton Harker" wrote in message
om...
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





All times are GMT +1. The time now is 09:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com