Find Replace to insert Carriage Returns

Bobichael

New Member
Joined
Dec 11, 2012
Messages
7
Someone please save me from losing my mind.

I'm working with a document that has several cells which require double carriage returns within cells. The location of each space is marked with an @ sign. A few weeks ago, I found an article online that explained how to do a find replace where the find value was '@' and the replace value was a series of numbers/characters that created a carriage return. When I doubled the carriage return code I got my two spaces. If I remember correctly, the string that I entered still appeared in the cell, so I needed to clean up afterwards by replacing that string with ' ', but it still left the line break.

I thought I bookmarked the page, but I can't find it again.

PLEASE HELP!!! What is the value that creates a carriage return?

Michael
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Find and Replace. In the top box enter @. In the lower box hold down ALT, type 010 on the numeric keypad thyen click Replace All.
 
Upvote 0
Find and Replace. In the top box enter @. In the lower box hold down ALT, type 010 on the numeric keypad thyen click Replace All.

Thanks, but I can't seem to get that to work. I am working on a Win7 VM running on a MAC, so I'm not sure if the alt key on my keyboard works differently.

I know there was definitely a combination other than 010 that gave me the desired effect. I think it was a special character and a number.
 
Upvote 0
Thanks, but I can't seem to get that to work. I am working on a Win7 VM running on a MAC, so I'm not sure if the alt key on my keyboard works differently.

I know there was definitely a combination other than 010 that gave me the desired effect. I think it was a special character and a number.
Did you try the Ctrl+j?
I don't know if it works on a Mac but it does the same as Alt+(numberpad)010 on a pc.

The Ctrl+j can also be doubled-up in the "Replace with" box which you seemed to want. I don't think you can do that with Alt+010 anyway.
 
Upvote 0
Did you try the Ctrl+j?
I don't know if it works on a Mac but it does the same as Alt+(numberpad)010 on a pc.

The Ctrl+j can also be doubled-up in the "Replace with" box which you seemed to want. I don't think you can do that with Alt+010 anyway.
I would think Peter's suggested CTRL+J should work for you, but in case it does not, you should be able to use the following macro... simply select all the cells you want to process and then run this macro...

Code:
Sub ReplaceAtSignWithLineFeed()
  Dim Cell As Range
  For Each Cell In Selection
    Cell = Replace(Cell.Value, "@", Chr(10))
  Next
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (ReplaceAtSignWithLineFeed) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for.
 
Upvote 0
I would think Peter's suggested CTRL+J should work for you, but in case it does not, you should be able to use the following macro... simply select all the cells you want to process and then run this macro...

Code:
Sub ReplaceAtSignWithLineFeed()
  Dim Cell As Range
  For Each Cell In Selection
    Cell = Replace(Cell.Value, "@", Chr(10))
  Next
End Sub
Maybe?
Code:
Sub ReplaceAtSignWithLineFeed_v2()
  Selection.Replace What:="@", Replacement:=Chr(10), LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
End Sub
or, for the double-replace ..

Replacement:=Chr(10) & Chr(10)
 
Upvote 0
Maybe?
Rich (BB code):
Sub ReplaceAtSignWithLineFeed_v2()
  Selection.Replace What:="@", Replacement:=Chr(10), LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
End Sub
No loop... good point. Another way (assuming the selection is contiguous)...
Rich (BB code):
Sub ReplaceAtSignWithLineFeed_v3()
  Selection = Evaluate("IF(ROW(),SUBSTITUTE(" & Selection.Address & ",""@"",CHAR(10)))")
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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