Really stupid XL question: Including carriage returns in a paste to one cell

In Microsoft Excel, how can I paste a block of text into a single cell? The text in question is a SQL statement and I’d like to preserve the formatting and paste it into one cell. But Excel splits it into multiple cells wherever there was a carriage return.

Any help would be appreciated.

Double-click in the cell, or click once in the formula bar at the top, then paste your copied text.

GorillaGirl

Just a couple of other tips. If I’m starting at too low a level for you, please accept my apologies. This has been part of my job for the last decade or so and the last several jobs I’ve had, and I’ve learned to start from the basics.

[ul][li]First, make sure that the cell you’re putting the text in is formatted to wrap text. To do this, go to the Format menu, then click on Cells. Check Wrap Text on the Alignment tab. Click on OK[/li]
[li]Copy the text you want to put into the cell. As GorillaGirl said, double click in the cell or click in Formula Bar which sits at the top of the screen.[/li]
[li]Paste your text.[/li]
[li]If you want force a line to break where you want it to, rather than letting Excel decide, while you’re editing the contents of the cell, press Alt + Enter. [/ul][/li]
Hope this helps,
CJ

Good advice, Siege. I’d forgotten about Alt + Enter for a line break. However, setting the wrap text property is unnecessary. The carriage returns in the original text will force Excel to wrap it as part of the paste operation.

I started playing around with this, and one thing I found is that the maximum row height is 409.5, or 546 pixels, and some of my test code wasn’t displayed. It was all in the cell, it just wasn’t showing up. For a relatively small number of lines, I could drop the font size, but for larger amounts of text, I ended up merging cells. Spectre of Pithecanthropus, try this if you have more than 32 lines of text and it looks like your pasted code is cut off.

Select the cell with text and the one below it, and follow Siege’s directions for wrapping, but check Merge cells as well. Make sure both boxes are checked, not empty or grayed out. Then re-size the row height of your merged cells. If your text is still cut off, select your merged cells and the one below, and merge cells & wrap text again. Continue doing this until all of your text displays properly.

Good luck. Sometimes getting Microsoft apps to do what you want is like trying to nail jello to a tree. :slight_smile:

Many thanks to both of you. Your information was very helpful.