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?
I have several spreadsheets that have unintended line breaks. Is there a way to find and replace this with a regular space?
Where are the line breaks? Within cells in a table or in text boxes? If in a table, in just one column?
SG
Hi MXVd,
If the line breaks are in cells, add another column to hold a formula with the SUBSTITUTE function
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
Regards,
Ian.
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).
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.
search and replace?
double click a cell with the line break (to enter text edit mode in the cell)
select the line break:
now select the menu item "Edit > Find > Use Selection for Find" (or key combination <command> + e)
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):
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?