I'm finding these increasingly harder to manipulate.
is there another way that avoids using the formula bar?
Some text editor that provides indentation perhaps?
You can press:
Ctrl + Enter on Windows
⌘ + Enter on a Mac
inside the formula editor bar to add new lines to your formulas in order to make them more readable.
To comment inside formulas, you can use N().
For example:
=SUM(A1:A)+N("This is a comment.")
this will give exactly the same result as:
=SUM(A1:A)
Note that:
N("This is a comment")
returns 0.
If you want to avoid that, you can use T(N("comment")) which acts like a blank string.
Example:
Probably not the best answer, but as I had the same problem before, what I do is copy the formula to a text editor (or pastebin), ident the formula, select all and then repaste in the google sheets formula. If pasted it will have a line break, like this:
={
ARRAYFORMULA(somecomplicatedstuffhere) ,
ARRAYFORMULA(moreformulashere)
}
Also, if you are inside the cell, you can add a newline this way:
Windows: Ctrl + Enter
Mac/ Linux: ⌘ + Option + Enter
Related
When I import a csv file to Google spreadsheet a single quote get added in front of all numeric data.
How can I remove that ?
I using import option from file menu
Try this:
right-click the column letter (on columns with numbers)
press Ctrl+F to invoke Google Sheets Search
to the right of the search box, click the ⋮ vertical 3 dots button
to invoke the Find and replace window
in the Find box, put the ' single quote (no space after)
leave the Replace box empty
click the Replace all button (on the bottom)
That should do the trick
put a column in notepad ++ enter image description here
make replace, and return column to GD
For me "Find and Replace" didn't work since those single quotes are not found by it.
I could only get rid of the single quotes by formatting affected cells/column as an integer numeric one.
I'm a bit of a newbie at this, so hope to get some help.
I have a large spreadsheet where columns C and D each have a blank space before the data in each column. Can some one please explain me how to trim an entire column to remove starting spaces in LibreOffice of Google Spreadsheets
In LibreOffice:
1. Select the cells you want to change
2. Edit -> Find & Replace
3. Find: ^\s+
4. Replace:
5. Other Options - Regular expressions: ON
6. Other Options - Current selection only: ON
7. Click Replace All
In Google Sheets, I would do the following.
First, enter the formula =arrayformula(trim(C:D)) in some cell of the first row, for example E1. It will fill two columns (E and F) with trimmed values (removing spaces at the beginning and end of each string).
Then copy the contents of columns E-F and paste values only in C-D; this is done with Ctrl-Shift-V, or by selecting "paste special -> values only" from the context manu.
In LibreOffice you can trim all spaces (beginning and end) via the "text to column" function:
Data -> "Text to Column"
Then assure the column is not being split (e.g. select tab als separator, if no tabs are present) and select "Trim spaces"
I'm sure the other answer works, but if you just need to do it once, I have an easy option. Download Sublime Text or some other text editor. Look for spaces at the beginning of a string (using ("^ ") without quotes should do it), and erase them.
Text editors are really helpful for normalizing data like this when you don't need updates in the future.
I did some searching and in openoffice and excel it looks like you can simply add an * at the beginning or end of a character to delete everything before and after it, but in Google spreadsheet this isn't working. Does it support this feature? So if I have:
keyword USD 0078945jg .12 N N 5748 8
And I want to remove USD and everything after it what do I use? I have tried:
USD* and (USD*) with regular expressions checked
But it doesn't work. Any ideas?
The * quantifier just needs to be applied to a dot (.) which will match any character.
To clarify: the * wildcard used in certain spreadsheet functions (eg COUNTIF) has a different usage to the * quantifier used in regular expressions.
In addition to options that would be available in Excel (LEFT + FIND) pointed out by pnuts, you can use a variety of regex tools available in Google Sheets for text searching / manipulation
For example, RegexReplace:
=REGEXREPLACE(A1,"(.*)USD.*","$1")
(.*) <- capture group () with zero or more * of any character .
USD.* <- exact match on USD followed by zero or more * of any character .
$1 <- replace with match in first capture group
Please try:
and also have a look at.
For spaces within keyword I suggest a helper column with a formula such as:
=left(A1,find("USD",A1)-1)
copied down to suit. The formula could be converted to values and the raw data (assumed to be in ColumnA) then deleted, if desired.
To add to the answers here, you can get into trouble when there are special characters in the text (I have been struggling with this for years).
You can put a frontslash \ in front of special characters such as ?, + or . to escape them. But I still got stuck when there were further special characters in the text. I finally figured it out after reading find and replace in google sheets with regex.
Example: I want to remove the number, period and space from the beginning of a question like this: 1. What is your name?
Go to Edit → Find and replace
In the Find field, enter the following: .+\. (note: this includes a space at the end).
Note: In the Find and replace dialogue box, be sure to check "Search using regular expressions" and "match case". Leave the Replace field blank.
The result will be this text only: What is your name?
I am trying to do a calculation of two cells, where one of them contains a number like this: 1 250.
If the number is written like that, and not 1250, then I cannot get the spreadsheet to do any calculations with it. Google suddenly do not treat it as a legit number anymore.
Why not just type 1250 instead of 1 250?
Well, I am getting the cell values from a html import function.
Any good advice on how to get around this?
Try something like this:
=Substitute(A2," ","")
In this formula, A2 is a cell. You are finding any spaces in that cell and then replacing it with a "non-space".
Use the substitute function to transform your number before using it in a formula. For instance, let's say you wanted to multiple F8 by 2, but F8 may contain spaces. You would then do:
=substitute(F8, " ","") * 2
Substitute didn't work form me. But these steps did:
Select one or several columns of data
Press Ctrl + H to get the "Find and Replace" dialog
Make sure "Search using regular expressions" is checked ✅
Enter \s to the "Find" field, and leave "Replace with" empty
Click on the "Replace all" button
Explanation:
\s is a regular expression matching any kind of whitespace character. There may have been some other kind of whitespace in my spreadsheet, not a regular " " (space) character, and that's why regex worked for me, while SUBSTITUTE() didn't.
I've also tried the REGEXREPLACE(A2, "\s", "") function, but it didn't seem to to anything in my case.
I have a column in open office like this:
abc-23
abc-32
abc-1
Now, I need to get only the sum of the numbers 23, 32 and 1 using a formula and regular expressions in calc.
How do I do that?
I tried
=SUMIF(F7:F16,"([:digit:].)$")
But somehow this does not work.
Starting with LibreOffice 6.4, you can use the newly added REGEX function to generically extract all numbers from a cell / text using a regular expression:
=REGEX(A1;"[^[:digit:]]";"";"g")
Replace A1 with the cell-reference you want to extract numbers from.
Explanation of REGEX function arguments:
Arguments are separated by a semicolon ;
A1: Value to extract numbers from. Can be a cell-reference (like A1) or a quoted text value (like "123abc"). The following regular expression will be applied to this cell / text.
"[^[:digit:]]": Match every character which is not a decimal digit. See also list of regular expressions in LibreOffice
The outer square brackets [] encapsulate the list of characters to search for
^ adds a NOT, meaning that every character not included in the search list is matched
[:digit:] represents any decimal digit
"": replace matching characters (every non-digit) with nothing = remove them
"g": replace all matches (don't stop after the first non-digit character)
Unfortunately Libre-Office only supports regex in find/replace and in search.
If this is a once-only deal, I would copy column A to column to B, then use [data] [text to columns] in B and use the - as a separator, leaving you with all the text in column B and the numbers in column C.
Alternatively, you could use =Right(A1,find("-",A1,1)+1) in column B, then sum Column C.
I think that this is not exactly what do you want, but maybe it can help you or others.
It is all about substring (in Calc called [MID][1] function):
First: Choose your cell (for example with "abc-23" content).
Secondly: Enter the start length ("british" --> start length 4 = tish).
After that: To print all remaining text, you can use the [LEN][2] function (known as length) with your cell ("abc-23") in parameter.
Code now looks like this:
D15="abc-23"
=MID(D15; 5; LEN(D15))
And the output is: 23
When you edit numbers (in this example 23), no problem. However, if you change anything before (text "abc-"), the algorithm collapses because the start length is defined to "5".
Paste the string in a cell, open search and replace dialog (ctrl + f) extended search option mark regular expression search for ([\s,0-9])([^0-9\s])+ and replace it with $1
adjust regex to your needs
I didn't figure out how to do this in OpenOffice/LibreOffice directly. After frustrations in searching online and trying various formulas, I realised my sheet was a simple CSV format, so I opened it up in vim and used vim's built-in sed-like feature to find/replace the text in vim command mode:
:%s/abc-//g
This only worked for me because there were no other columns with this matching text. If there are other columns with the same text, then the solution would be a bit more complex.
If your sheet is not a CSV, you could copy the column out to a text file and use vim to find/replace, and then paste the data back into the spreadsheet. For me, this was a lot less frustrating than trying to figure this out in LibreOffice...
I won't bother with a solution without knowing if there really is interest, but, you could write a macro to do this. Extract all the numbers and then implement the sum by checking for contained numbers in the text.