[Solved] Convert multi-line data in cell to single line

Discuss the spreadsheet application
Locked
Analise01
Posts: 2
Joined: Sat Aug 16, 2025 3:21 pm

[Solved] Convert multi-line data in cell to single line

Post by Analise01 »

Hi

Firstly apologies if this has been posted elsewhere - I tried searching first.

I have a calc spreadsheet with two to three columns of data. The first column has one line per cell, however the second and third columns have cells with both only one line of text, and multiple lines of text in each cell. I would like to rearrange the data in cells that have multiple lines of text to all be on the same line. As my original document has over 5,000 rows, doing this individually is not practical.

I have uploaded a picture of a dummy spreadsheet with an example of what the data looks like on the left, and how I would like it to be on the right.

I would appreciate any help. Thank you.
Attachments
workspace_manual_234532_as.png
workspace_manual_234532_as.png (97.79 KiB) Viewed 2516 times
Last edited by Analise01 on Wed Aug 20, 2025 9:10 am, edited 1 time in total.
Windows 11, Open Office 4.1.7
User avatar
karolus
Volunteer
Posts: 1252
Joined: Sat Jul 02, 2011 9:47 am

Re: Rearranging multiple lines of data inside same cells in same column

Post by karolus »

Hallo
use ⇒ Find and replace:
search:

Code: Select all

# search for
\n
#replace: 
<literal space>
[x]regular Expression

⇒⇒ replace all
Last edited by karolus on Sat Aug 16, 2025 7:28 pm, edited 1 time in total.
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
FJCC
Moderator
Posts: 9640
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Rearranging multiple lines of data inside same cells in same column

Post by FJCC »

Try this on a copy of your document.
Open the Find & Replace dialog using the menu Edit -> Find & Replace.
In the Search For box, enter \n
In the Replace With box enter a space character
Click More Options and select the box labeled Regular Expressions
Optional - Click the Find All button an check that the cells you expect to change are selected
Click Replace All.

If that doesn't work for you, please upload a sample file, not an image, and explain what was wrong with the result of the above steps.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Lupp
Volunteer
Posts: 3761
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Rearranging multiple lines of data inside same cells in same column

Post by Lupp »

My two cents:
1. Don't use whitespace again to separate the former lines. Use a visible separator like "/" for the purpose.
2. You can also create a second sheet, and there use a formula like

Code: Select all

=SUBSTITUTE(A1; CHAR(10); "/")
filled right and down to as many columns/rows as you need. The formula will adapt as needed due to the relative addressing.
CHAR(10) is the whitespace character used in Calc cells for "go to new line".
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Analise01
Posts: 2
Joined: Sat Aug 16, 2025 3:21 pm

Re: Rearranging multiple lines of data inside same cells in same column

Post by Analise01 »

Hi everyone, apologies for the late reply. Thank you all for your help - this has now worked on my document.
Windows 11, Open Office 4.1.7
Locked