Remove line break within cell google spreadsheet - google-sheets

Is there an easy way to remove the line breaks within each cell?
Each cell on column E, has extra line that I am having to manually remove, any easy to remove all.

Easiest method:
Bring up the Find and Replace box (Ctrl+h on Windows)
Tick the box Search with regular expressions
In the Find input field, type \n
Leave the Replace with field empty
Click Replace all
(If there are still spaces left, click Replace all again)

How about following sample? This sample supposes that the line break is \r\n and \n.
FLow :
Retrieve the information of line break.
If the line break is \r\n, when the number of \r\n is more than 2, it is modified to char(10).
Sample :
=IF(REGEXMATCH(E1, "\r\n"),REGEXREPLACE(E1, "(\r\n){2,}", char(10)),REGEXREPLACE(E1, "(\n){2,}", char(10)))
Result :
If you want to remove all of the line break, you can use =CLEAN(A1). In this case, the result of the result sheet becomes sample1sample2sample3sample4sample5.
If this was not helpful for you, I'm sorry.

Here is my preferred method to remove leading and trailing line breaks. Note that this will not remove any line breaks in the "middle" of your cells.
Right click on Column E > Insert 1 Right
In column F in the first row that has an extra space: Type the formula =TRIM( select the E cell directly to the right, and enter a closing ). For example, in F2 the formula should look like =TRIM(E2).
This cell should display the correct value. Select this cell and drag the little blue box in the bottom right corner to the bottom of your sheet. This will copy the formula to all other cells, updating the row E references.
When all the data in row F looks as expected, click on the very top of the row to select it and click copy.
Right click on the top of row F again and select Paste Special > Paste Values Only.
Now that Column F has the data you need, you can right click on the top of Row E > Delete column.

Here is the formula I use:
=TRIM(SUBSTITUTE(E2,CHAR(10)," "))
The value CHAR(10) will identify new lines and replace it with a " ".
And the TRIM will remove multiple white spaces.

Related

Why does copying multi-row text from Google Sheets to the Instagram caption box add a quote mark at the beginning and end of the text?

This may be the most niche question ever but let's try it anyway.
I have a Google Sheets spreadsheet that contains cells with multiple lines of text. Each line of text is separated by a soft break.
As shown below, when I copy the contents of a cell (row 2 in the screenshot) from the Google Sheets app to the Instagram caption box, a quote mark is added to the beginning and end of the caption.
If I copy the contents of a cell and that cell has only a single line of text (row 3 in the screenshot), no quote mark is added.
I am using an iPhone 11 running the latest version of iOS.
The extra quotes are added when there are special characters in the cell. In your scenario, the Line Feed characters are causing this. Definitely annoying.
There is a way around this – using Carriage Return characters, rather than Line Feeds to separate each line. For some reason these characters don’t cause the quotation marks to appear.
One thing you can do in your sheet is to create a helper cell that will take your text, and replace the line feeds with carriage returns (assuming your input text is in cell A2, add this formula to an empty cell):
=SUBSTITUTE(A2,char(10),char(13))
The output for this will look like it doesn’t contain linefeeds, but when you copy & paste from that cell, the linefeeds will be there in the pasted text, without the extra quotation marks.
The quotations are inserted by the target application when non-printable or otherwise incompatible characters appear in the copied text. There are several scenarios in which the quotes don't appear, and several in which they do.
For example in the MacOS Notes application, consider a cell containing either a vertical tab (appearing as a line break in a single cell with a Cmd-Enter on Mac or Cntl-Enter on Windows) or a newline character in a formula such as ="test"&char(10)&"test". When copied and pasted into a record in Notes, the text is copied as is (i.e., as expected). However when pasting into the Notes search box, the quotes appear, such as described in the question.
There appear to be 3 alternative ways to handle this issue:
Strip the non-printable characters with a formula
Using the CLEAN function, the characters will be stripped. This will produce oft undesirable results, but will eliminate the quotes. See the Wrapped in CLEAN column:
Paste elsewhere first
In the Notes example, one can paste the offending text into a Note (or presumably any text editor.) The offending quotes are omitted. The text can then be recopied and repasted without quotes. This will still collapse a line feed into a space:
Publish to Web and copy from there
Publishing a sheet with non-printable characters enables quoteless copy, like the previous option, but may be a preferable. See the test sheet
Copy from the Sample Text column. You can paste without quotes, but the line break is stripped and replaced with a space as above.
this is a common issue. the solution would be to paste your copy into fx bar instead of cell selection. this way you can skip the additional quotes
The easiest of the easiest solution is to copy straight from the cell. Mark the text within the cell instead of marking the whole cell and then copy.
its very easy guys
just follow as i say
step1: type letter in a cell
step2: select logo(A) with 4 dash(-) which is on top
step3: select cell
step4:turn on wrap text
problem solved
if you are using desktop
mac: alt/opttion+enter
windows: alt+enter
you can also select all cell at once then you can select format on menu bar and select text warping and then wrap(this is not recommended as it may destroy your table format)

Conditional Formatting based on column values

I'm trying to make a column change color whenever a specific range within that same column has the same character, per example, I want cells C1:C50 to change to the color green when all the cells in C10:C50 have the value 1 on them.
I've tried this custom formula, that doesn't seem to work.
=C10:C50=CHAR(10004)
Sorry if this is an easy fix, but have been looking for answers and haven't found something that suits my problem
This should get you what you're after:
Select the rows you want the conditional format to apply to.
Click format > conditional formatting
Click + Add another rule
Below "Format Rules" click the drop down and select Is equal to
Type what you want the box to be equal to in the input (for example, "1" in your case)
Click the "Done" button.
Behold your beautifully formatted sheet and the new found power that you wield!
try:
=COUNTIF(C$10:C$50, CHAR(10004))=50

How to copy or get google sheet cell reference as string easily?

I hava a cell which is b30 in sheet sheet-alpha, I want get reference as string into clipboard, literally I want my clipboard contains string 'sheet-alpha'!B30
How do I do that in google sheet?
One solution to your need can be achieved in 2 steps:
First, open [top menu] Extensions > Apps Script and copy&paste the following function:
function getSheetName() {
var sheetName = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
return sheetName;
}
The above code enables you to call the sheet name from wherever you need it by using the formula =getSheetName() in any cell.
Then, add another column to the right of column B (new Column C) and copy&paste the following array formula at the top most cell:
={"Ref 2 Str"; ARRAYFORMULA(IF(B2:B="","","'"&getSheetName()&"'!B:"&INDEX(ROW(INDIRECT("A"&(ROW()+1)&":A")))))}
The above function looks for non-empty cells on column B and for each non-empty cell it puts in column C the string reference for the corresponding cell in column B (in the format you need).
Pressing
Ctrl `
(the backtick under the tilde, top left of most keyboards) will toggle between showing or hiding the formulas in your worksheet. When the formula is showing you can copy in the normal way with Ctrl C.

Function to add 3 rows together in OpenOffice Calc then drag function down for 195,000 rows

I have a spreadsheet with 195,000 rows, There are 3 columns with different numbers in in the 4th column (D1) I enter =A1+B1+C1 and it comes up with the answer, But I can only drag down the AutoSum feature slowly.
Is there a way to automate it so I can have the Autosum for all columns in D so it'd be D1 : D195000?
Here is a simple trick you can do: Write your type on the first cell (D1) and anything to the last one (D198K - use the Navigator tool (F5) to go there fast). Then, copy the cell from the first cell, and press Ctrl + Shift + End (selection till the last cell that contains data) and then make a Paste.
This should paste the type to the selected shells, applying the type in analogy to each cell - unless you have used $ in the type for a cell row and/or column, in order to preserve a cell.
You could simply follow this logic in order to create your own function in OpenOffice Calc.

Apply formula to the entire column

I'm changing all the zip codes from Column A into Column B with the formula:
=TEXT(A1,"00000")
Like this:
I want every cell in Column B to be transformed using the formula above. But I have over 40,000 rows, so it is not feasible to drag the formula down to apply it to the entire Column B because it takes so long.
Are there any alternatives to dragging?
It looks like some of the other answers have become outdated, but for me this worked:
Click on the cell with the text/formula to copy
Shift+Click on the last cell to copy to
Ctrl + Enter (Cmd + Enter on Mac.)
(Note that this replaces text if the destination cells aren't empty)
I think it's a more recent feature, but...
Double clicking the square on the bottom right of the highlighted cell copies the formula of the highlighted cell.
I think you are in luck. Please try entering in B1:
=text(A1:A,"00000")
(very similar!) but before hitting Enter hit Ctrl+Shift+Enter.
This is a shortcut for wrapping the formula with ArrayFormula():
=ArrayFormula(text(A1:A,"00000"))
This worked for me:
Input the formula in the first cell.
Press Enter.
Click on the first cell and press Ctrl + Shift + down_arrow. This will select the last cell in the column used on the worksheet.
Ctrl + D. This will fill copy the formula in the remaining cells.
This is for those who want to overwrite the column cells quickly (without cutting and copying). This is the same as double-clicking the cell box but unlike double-clicking, it still works after the first try.
Select the column cell you would like to copy downwards
Press Ctrl+Shift+⇓ to select the cells below
Press Ctrl+Enter to copy the contents of the first cell into the cells below
BONUS:
The shortcut for going to the bottom-most content (to double-check the copy) is Ctrl+⇓. To go back up you can use Ctrl+⇑ but if your top rows are frozen you'll also have to press Enter a few times.
For Mac:
Click on the first cell having the formula and press Ctrl + Shift + down_arrow. This will select the last cell in the column used on the worksheet.
Command + D
(don't use ctrl). This will fill the formula in the remaining cells.
Let's say you want to substitute something in an array of string and you don't want to perform the copy-paste on your entire sheet.
Let's take this as an example:
String array in column "A": {apple, banana, orange, ..., avocado}
You want to substitute the char of "a" to "x" to have: {xpple, bxnxnx,
orxnge, ..., xvocado}
To apply this formula on the entire column (array) in a clean an elegant way, you can do:
=ARRAYFORMULA(SUBSTITUE(A:A, "a", "x"))
It works for 2D-arrays as well, let's say:
=ARRAYFORMULA(SUBSTITUE(A2:D83, "a", "x"))
Found another solution:
Apply the formula to the first 3 or 4 cells of the column
Ctrl + C the formula in one of the last rows (if you copy the first line it won't work)
Click on the column header to select the whole column
Press Ctrl + V to paste it in all cells bellow
Just so I don't lose my answer that works:
Select the cell to copy
Select the final cell in the column
Press CTRL+D
You can use Ctrl+Shift+Down+D to add the formula to every cell in the column as well.
Simply click/highlight the cell with the equation/formula you want to copy and then hold down Ctrl+Shift+Down+D and your formula will be added to each cell.
The exact formula is:
=ArrayFormula(text(A1:A,"00000"))
ArrayFormula works on multiple rows (in the above example, every row), and results are placed in the cell with the formula and the cells below it in the same column. It looks as if the same formula was copied into all those rows.
If any of the cells in that column are not empty, they won't get overwritten. Instead, you will get an error message.
To save yourself typing, you can use the trick from the answer above by pnuts:
Type: =text(A1:A,"00000") and then hit the following key combination:
On windows: Ctrl+Shift+Enter
On a MAC: Command+Shift+Enter
This will convert the formula to ArrayFormula.
After hitting the key combination, you need to hit Enter, to actually apply the converted formula.
If your sheet contains header row(s), and you want to apply formula from (for example) row 5 on, you would use =text(A5:A,"00000") instead.
This answer includes information from pnuts's answer and LOAS's comment.
Lambda Solution
Using the new LAMBDA and MAP functions, this is now doable without an ArrayFormula or having to drag anything.
=MAP(A2:A6, LAMBDA(value, TEXT(value, "00000")))
LAMBDA defines a function. value is the parameter, which we can use in the formula expression.
MAP applies the LAMBDA to each value in the given range. This also works on 2D ranges.
To be clear when you us the drag indicator it will only copy the cell values down the column whilst there is a value in the adjacent cell in a given row.
As soon as the drag operation sees an adjacent cell that is blank it will stop copying the formula down.
.e.g
1,a,b
2,a
3,
4,a
If the above is a spreadsheet then using the double click drag indicator on the 'b' cell will fill row 2 but not row three or four.
Well, Another easiest and simplest way is as in my file rows were above 16000, which is pretty huge number. So steps which helped me are:
1. Select the cell in which formula is written.
2. Then go to NameBox(it is the box which tells about active cell). Here in my case it was the cell where was formula was written(i.e P2).
3. Then in that cell type your active cell number:your last row.For example last row of my column was 16745 and formula was written in P2.
So write P2:P16745,
4. Press Enter in Name Box and bingo your whole area of column till last row is selected.
5. Now press Ctrl+D(Windows)
try:
=INDEX(TEXT(A2:A; "00000"))
advantages: short, works, smells nice
to map out empty cells you can do:
=INDEX(IF(A2:A="";;TEXT(A2:A; "00000")))
Reading the answers here did not quite work for me, but a combination did. Here are my steps (Windows, Chrome):
Select the cell with the formula you want to apply to the column (for the whole column, ensure this is the top cell)
Ctrl + Shift + Down (selects all below cells)
Ctrl + D (apply formula)
Done!
Based on:
https://stackoverflow.com/a/61112723/3200858
https://stackoverflow.com/a/51411774/3200858
You may fill the column by double-clicking on the bottom right hand corner of the cell which you want to copy from (the point on the box that you would otherwise drag) and it will be applied to whole column.
NB: This doesn't work if you have the filter applied, nor if there is already something already in the cells below.

Resources