Adding carriage returns to cells from a userform

Andy Gee

New Member
Joined
Feb 26, 2002
Messages
48
Hi, I have a multiline textbox in a userform and would like to be able to:
1. Hit return for a new line.
2: Change the carriage returns to
, the html version of a new line.
Then copy the result into a cell.

Please help I'm really stuck!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hello Andy:
1. On your userform property, make sure the textbox's enterkeybehavior is set to true, this enable the enter key to generate a new line.
2. the new line character is either chr(13) then chr(10) or chr(10) then chr(13), I forget which one is the right one, but you can easily test it. just do a search and replace of both character with the html ones.
example:
dim strAns as string
strAns = textbox1.text
strAns = replace (strAns,chr(13) & chr (10)," ")

3. not sure what you mean, but it should be easy once you got the string above? :)

HTH
lantiger
 
Upvote 0
oops, guess I should disable HTML :)

on the above post, where it has the replace function, it should be:
strAns = replace(strAns, chr(13) & chr (10), "@nbsp;"
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,272
Members
448,558
Latest member
aivin

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