ASCII character for hard return in VBA excel

shornco

Board Regular
Joined
Feb 4, 2003
Messages
91
I'm writing text for a cell in VBA code. I want a hard return in the middle of my sentence and can't find the right combination of ASCII characters. In Access I've always used the combination Chr(13) & Chr(10), but both of those characters are giving me the box symbol in the middle of my text. This is what I have:

ActiveCell = "This is my first row of text" & Chr(13) & Chr(10) & "this is my second row of text."

I've also tried Chr(13) by itself and Chr(10) by itself. Any ideas?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try formatting the cell to wordwrap.

Cells>Format>Alignment and check Wrap Text.
 
Upvote 0
I use Chr(10) for a hard return all the time. I think Norie's right. When a cell is not formatted to be wrapped, the hard return shows up as that square symbol.
 
Upvote 0

Forum statistics

Threads
1,203,741
Messages
6,057,097
Members
444,905
Latest member
Iamtryingman

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