Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to a remove line breaks from cells in Numbers?

I have several spreadsheets that have unintended line breaks. Is there a way to find and replace this with a regular space?

Posted on Feb 25, 2015 9:04 PM

Reply
5 replies

Feb 26, 2015 1:10 AM in response to MXVd

Hi MXVd,


If the line breaks are in cells, add another column to hold a formula with the SUBSTITUTE function

User uploaded file

Formula in C2 (and Fill Down)

=SUBSTITUTE(B2,"

"," ",1)


The newline character is enclosed by quotes and is option enter.

The replace with character is a space enclosed by quotes.


Here it is in Pages (just to illustrate) with Menu > View > Show Invisibles

User uploaded file

Regards,

Ian.

Feb 26, 2015 2:18 AM in response to MXVd

Hi MXVd,


Update with an improved formula. Leave out the 1 at the end of the formula. Then it will SUBSTITUTE all line breaks within a cell (without errors if there are no line breaks).

User uploaded file

Formula in C2 (and Fill Down)

=SUBSTITUTE(B2,"

"," ")


Select Column C, Copy, then Menu > Edit > Paste Formula Results. That will "fix" the values and you can delete Column B.


Regards,

Ian.

Feb 26, 2015 6:09 AM in response to MXVd

search and replace?


double click a cell with the line break (to enter text edit mode in the cell)

select the line break:

User uploaded file


now select the menu item "Edit > Find > Use Selection for Find" (or key combination <command> + e)


User uploaded file


then enter the character (or string) you want to replace the new lines with in the bottom field of the "Find & Replace" dialog (the one with the pencil):

User uploaded file

Feb 26, 2015 3:04 PM in response to MXVd

If the unwanted line breaks are in many different cells and you don't want to fiddle around with extra columns and formulas, then you can just select the cells in the range you want to clear of line breaks, and with the cells selected, run this script. (Just copy-paste it into Script Editor and hit the triangle run button.)


property removeThis : "

" -- type exactly one line break between the "". I typed control-return.

property replaceWith : " " -- space

tell application "Numbers"

tell front document to tell active sheet

tell (first table whose selection range's class is range)

set theSelection to selection range

tell theSelection to repeat with aCell in cells

set aCell'svalue to my replaceChars(aCell'svalue as string, removeThis, replaceWith)

end repeat

end tell

end tell

end tell


to replaceChars(theText, searchStr, replaceStr)

set AppleScript'stext item delimiters to searchStr

set textItems to theText'stext items

set AppleScript'stext item delimiters to replaceStr

set theText to textItems as string

set AppleScript'stext item delimiters to ""

return theText

end replaceChars



Note that you have to delete the character between the "" then type control-return so the second " appears on the next line.


SG

How to a remove line breaks from cells in Numbers?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.